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