typst/vendor/csv/examples/tutorial-read-serde-03.rs
2024-10-16 14:18:46 +03:00

23 lines
533 B
Rust

use std::collections::HashMap;
use std::{error::Error, io, process};
// This introduces a type alias so that we can conveniently reference our
// record type.
type Record = HashMap<String, String>;
fn run() -> Result<(), Box<dyn Error>> {
let mut rdr = csv::Reader::from_reader(io::stdin());
for result in rdr.deserialize() {
let record: Record = result?;
println!("{:?}", record);
}
Ok(())
}
fn main() {
if let Err(err) = run() {
println!("{}", err);
process::exit(1);
}
}