aboutsummaryrefslogtreecommitdiff
path: root/examples/tutorial-error-02.rs
blob: c3fc191332bcb1f8a8c1d19c9d78aca47e992331 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::{io, process};

fn main() {
    let mut rdr = csv::Reader::from_reader(io::stdin());
    for result in rdr.records() {
        // Examine our Result.
        // If there was no problem, print the record.
        // Otherwise, print the error message and quit the program.
        match result {
            Ok(record) => println!("{:?}", record),
            Err(err) => {
                println!("error reading CSV from <stdin>: {}", err);
                process::exit(1);
            }
        }
    }
}