1 use std::{error::Error, io, process}; 2 main()3fn main() { 4 if let Err(err) = run() { 5 println!("{}", err); 6 process::exit(1); 7 } 8 } 9 run() -> Result<(), Box<dyn Error>>10fn run() -> Result<(), Box<dyn Error>> { 11 let mut rdr = csv::Reader::from_reader(io::stdin()); 12 for result in rdr.records() { 13 // Examine our Result. 14 // If there was no problem, print the record. 15 // Otherwise, convert our error to a Box<dyn Error> and return it. 16 match result { 17 Err(err) => return Err(From::from(err)), 18 Ok(record) => { 19 println!("{:?}", record); 20 } 21 } 22 } 23 Ok(()) 24 } 25