1 use std::error::Error; 2 use std::io; 3 use std::process; 4 run() -> Result<u64, Box<dyn Error>>5fn run() -> Result<u64, Box<dyn Error>> { 6 let mut rdr = csv::Reader::from_reader(io::stdin()); 7 8 let mut count = 0; 9 for result in rdr.byte_records() { 10 let record = result?; 11 if &record[0] == b"us" && &record[3] == b"MA" { 12 count += 1; 13 } 14 } 15 Ok(count) 16 } 17 main()18fn main() { 19 match run() { 20 Ok(count) => { 21 println!("{}", count); 22 } 23 Err(err) => { 24 println!("{}", err); 25 process::exit(1); 26 } 27 } 28 } 29