Dump parsing from Reader
Closed this issue · 0 comments
rye commented
From the rust-csv readme, this looks like some syntax we can use.
fn example() -> Result<(), Box<Error>> {
// Build the CSV reader and iterate over each record.
let mut rdr = csv::Reader::from_reader(io::stdin());
for result in rdr.records() {
// The iterator yields Result<StringRecord, Error>, so we check the
// error here.
let record = result?;
println!("{:?}", record);
}
Ok(())
}
Note the ?
is the carrier operator, which is syntactic sugar for the try!
macro. Functionally, the let record = result?
would return early if there was an error.