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