Function serdeconv::to_toml_string

source ·
pub fn to_toml_string<T>(value: &T) -> Result<String>where
    T: ?Sized + Serialize,
Expand description

Converts the value to a TOML string.

Examples

extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serdeconv;

// Defines a serializable struct.
#[derive(Serialize)]
struct Foo {
    bar: &'static str,
    baz: usize
}

// Converts the `Foo` value to a TOML string.
let foo = Foo { bar: "aaa", baz: 123 };
let toml = serdeconv::to_toml_string(&foo).unwrap();
assert_eq!(toml, "\
bar = \"aaa\"
baz = 123
");