[][src]Function toml::de::from_str

pub fn from_str<'de, T>(s: &'de str) -> Result<T, Error> where
    T: Deserialize<'de>, 

Deserializes a string into a type.

This function will attempt to interpret s as a TOML document and deserialize T from the document.


extern crate serde_derive;
extern crate toml;

struct Config {
    title: String,
    owner: Owner,

struct Owner {
    name: String,

fn main() {
    let config: Config = toml::from_str(r#"
        title = 'TOML Example'

        name = 'Lisa'

    assert_eq!(config.title, "TOML Example");
    assert_eq!(config.owner.name, "Lisa");