Function tomlconv::to_toml_string [] [src]

pub fn to_toml_string<T: ?Sized>(value: &T) -> Result<String> where
    T: Serialize

Converts the value to a TOML string.

Examples

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

// 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 = tomlconv::to_toml_string(&foo).unwrap();
assert_eq!(toml, "\
bar = \"aaa\"
baz = 123
");