toml
toml copied to clipboard
Serialization of keys varies depending on whether the feature flag "parse" is enabled
If this feature flag is disabled, then all keys are double quoted, otherwise they aren't (unless necessary).
Code to reproduce:
use serde::Serialize;
use std::collections::BTreeMap;
#[derive(Serialize)]
struct Example {
name: String,
extra: BTreeMap<String, u8>,
}
fn main() {
let example = Example {
name: "Example".into(),
extra: (0..3)
.map(|i| (format!("{}", (b'a' + i) as char), i))
.collect(),
};
println!("{}", toml::to_string_pretty(&example).unwrap());
}
Output with default-features = false, features = ["display"]
:
"name" = "Example"
["extra"]
"a" = 0
"b" = 1
"c" = 2
Output with default features:
name = "Example"
[extra]
a = 0
b = 1
c = 2