[go: up one dir, main page]

from_str

Function from_str 

Source
pub fn from_str<T>(s: &str) -> Result<T>
Expand description

Deserialize an instance of type T from a string of Hjson text

ยงExample

use serde::Deserialize;

#[derive(Deserialize, Debug)]
struct User {
    hands: Option<u16>,
    location: String,
}

// The type of `j` is `&str`
let j = "
    hands: 2
    location: Menlo Park, CA
";

let u: User = deser_hjson::from_str(j).unwrap();
println!("{:#?}", u);