Use spaces for CSV in indentation

The use of tabs for indentation made the example error due to finding more
columns on the indented lines than intended. Use escaped newlines and line
continuations to prevent the indentation from being part of the records.
This commit is contained in:
Dirkjan Ochtman 2021-03-17 14:22:36 +01:00
parent 752b035c1a
commit cc02ec8507

View file

@ -18,9 +18,9 @@ struct Record {
use csv::ReaderBuilder;
fn main() -> Result<(), Error> {
let data = "name\tplace\tid
Mark\tMelbourne\t46
Ashley\tZurich\t92";
let data = "name\tplace\tid\n\
Mark\tMelbourne\t46\n\
Ashley\tZurich\t92";
let mut reader = ReaderBuilder::new().delimiter(b'\t').from_reader(data.as_bytes());
for result in reader.deserialize::<Record>() {