2017-02-08 23:36:38 -06:00
|
|
|
extern crate toml;
|
|
|
|
extern crate serde;
|
|
|
|
|
|
|
|
use serde::de::Deserialize;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn main() {
|
2017-03-31 20:45:00 -05:00
|
|
|
let s = "
|
|
|
|
[a] foo = 1
|
|
|
|
[[b]] foo = 1
|
|
|
|
";
|
|
|
|
assert!(s.parse::<toml::Value>().is_err());
|
2017-02-08 23:36:38 -06:00
|
|
|
|
2017-03-31 20:45:00 -05:00
|
|
|
let mut d = toml::de::Deserializer::new(s);
|
2017-02-08 23:36:38 -06:00
|
|
|
d.set_require_newline_after_table(false);
|
|
|
|
let value = toml::Value::deserialize(&mut d).unwrap();
|
|
|
|
assert_eq!(value["a"]["foo"].as_integer(), Some(1));
|
2017-03-31 20:45:00 -05:00
|
|
|
assert_eq!(value["b"][0]["foo"].as_integer(), Some(1));
|
2017-02-08 23:36:38 -06:00
|
|
|
}
|