Skip to main content

to_csv

Function to_csv 

Source
pub fn to_csv<R, C, S>(rows: R) -> String
where R: IntoIterator<Item = C>, C: IntoIterator<Item = Cell<S>>, S: AsRef<str>,
Expand description

The table as CSV: one record per row, fields separated by ,, records ended by CRLF (RFC 4180 §2). See to_delimited.

use unparser_shared::csv::{to_csv, Cell};

let rows = [
    vec![Cell::single("Item"), Cell::single("Note")],
    vec![Cell::single("Bolt, M6"), Cell::single("He said \"no\"")],
];
assert_eq!(to_csv(rows), "Item,Note\r\n\"Bolt, M6\",\"He said \"\"no\"\"\"\r\n");