pub fn to_string<T: Serialize + ?Sized>(value: &T) -> Result<String, Error>Expand description
Serializes the records of a value to delimited text.
This uses the default SerializerConfig (CSV), see there for more
information.
#[derive(deser::Serialize)]
struct Row {
name: &'static str,
tags: Vec<&'static str>,
}
#[derive(deser::Serialize)]
struct Tagged {
name: &'static str,
#[deser(as = deser::adapters::Separated<';'>)]
tags: Vec<&'static str>,
}
let row = Tagged { name: "a", tags: vec!["x", "y"] };
assert_eq!(deser_csv::to_string(&[row]).unwrap(), "name,tags\na,x;y\n");
let row = Row { name: "a", tags: vec!["x", "y"] };
assert!(deser_csv::to_string(&[row]).is_err());