from_str

Function from_str 

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

Deserialize a TOON-formatted string to a value

§Arguments

  • s - The TOON-formatted string to deserialize

§Returns

A Result containing the deserialized value or an error

§Example

use serde::Deserialize;
use toon_rust::from_str;

#[derive(Deserialize)]
struct Product {
    sku: String,
    qty: u32,
}

let toon = "sku: A1\nqty: 2";
let product: Product = from_str(toon).unwrap();