Skip to main content

from_str

Function from_str 

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

Deserializes the records of a string.

This uses the default DeserializerConfig (CSV with a header), see the crate documentation for how records map onto deser.

#[derive(deser::Deserialize)]
struct Row {
    name: String,
    score: f64,
}

let rows: Vec<Row> =
    deser_csv::from_str("name,score\na,1.5\nb,2\n").unwrap();
assert_eq!(rows[1].score, 2.0);