serde_html_form::ser

Function push_to_string

Source
pub fn push_to_string<T: Serialize>(
    target: &mut String,
    input: T,
) -> Result<(), Error>
Expand description

Serializes a value into the provided application/x-www-form-urlencoded String buffer.

let meal = &[("bread", "baguette"), ("cheese", "comté"), ("meat", "ham"), ("fat", "butter")];

let mut target = "/cook?".to_owned();

serde_html_form::ser::push_to_string(&mut target, meal).unwrap();

assert_eq!(target, "/cook?bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter");