1 use std::{error::Error, io, process};
2
3 // This introduces a type alias so that we can conveniently reference our
4 // record type.
5 type Record = (String, String, Option<u64>, f64, f64);
6
run() -> Result<(), Box<dyn Error>>7 fn run() -> Result<(), Box<dyn Error>> {
8 let mut rdr = csv::Reader::from_reader(io::stdin());
9 // Instead of creating an iterator with the `records` method, we create
10 // an iterator with the `deserialize` method.
11 for result in rdr.deserialize() {
12 // We must tell Serde what type we want to deserialize into.
13 let record: Record = result?;
14 println!("{:?}", record);
15 }
16 Ok(())
17 }
18
main()19 fn main() {
20 if let Err(err) = run() {
21 println!("{}", err);
22 process::exit(1);
23 }
24 }
25