pub fn from_toml_str<T>(toml: &str) -> Result<T>where
T: DeserializeOwned,
Expand description
Converts from the TOML string to a value of T
type.
ยงExamples
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serdeconv;
// Defines a deserializable struct.
#[derive(Deserialize)]
struct Foo {
bar: String,
baz: usize
}
// Converts from the TOML string to a `Foo` value.
let toml = r#"
bar = "aaa"
baz = 123
"#;
let foo: Foo = serdeconv::from_toml_str(toml).unwrap();
assert_eq!(foo.bar, "aaa");
assert_eq!(foo.baz, 123);