例如:
#[macro_use]
extern crate serde_derive;
extern crate toml;
#[derive(Deserialize)]
struct Entry {
foo: String,
bar: String,
}
let toml_string = r#"
[[entry]]
foo = "a0"
bar = "b0"
[[entry]]
foo = "a1"
bar = "b1"
"#;
let config: toml::value::Table<Entry> = toml::from_str(&toml_string)?;
但是,这不起作用,并且会引发关于意外类型参数的错误Table
。