Function cni_format::to_str[][src]

pub fn to_str<I, K, V>(data: I) -> String where
    I: IntoIterator<Item = (K, V)>,
    K: AsRef<str>,
    V: ToString

Turn a key/value store into CNI format text. Accepts a wide range of keys, values and map types. The output will contain as few section headers as possible, but if a key consists of multiple parts separated by a dot, the first one will always be used for the section name

let mut map = std::collections::HashMap::new();
map.insert("a", "b");

assert_eq!(
    &cni_format::to_str(map),
    "a = b\n"
);

assert_eq!(
    &cni_format::to_str(vec![
        ("a.b", "c"),
    ]),
    "[a]\nb = c\n"
);