Function serdeconv::from_toml_str [] [src]

pub fn from_toml_str<'a, T>(toml: &'a str) -> Result<T> where
    T: Deserialize<'a>, 

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);