Function serde_urlencoded::to_string

source ·
pub fn to_string<T: Serialize>(input: T) -> Result<String, Error>
Expand description

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

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

assert_eq!(
    serde_urlencoded::to_string(meal),
    Ok("bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter".to_owned()));