Skip to main content

from_str_borrowed

Function from_str_borrowed 

Source
pub fn from_str_borrowed<'input, 'facet, T>(
    input: &'input str,
) -> Result<T, DeserializeError<CsvError>>
where T: Facet<'facet>, 'input: 'facet,
Expand description

Deserialize a value from a CSV string, allowing zero-copy borrowing.

ยงExample

use facet::Facet;
use facet_csv::from_str_borrowed;

#[derive(Facet, Debug, PartialEq)]
struct Person {
    name: String,
    age: u32,
}

let csv = "Alice,30";
let person: Person = from_str_borrowed(csv).unwrap();
assert_eq!(person.name, "Alice");
assert_eq!(person.age, 30);