1 use std::{error::Error, io, process};
2
example() -> Result<(), Box<dyn Error>>3 fn example() -> Result<(), Box<dyn Error>> {
4 let mut wtr = csv::Writer::from_writer(io::stdout());
5
6 // When writing records without Serde, the header record is written just
7 // like any other record.
8 wtr.write_record(&["city", "region", "country", "population"])?;
9 wtr.write_record(&["Southborough", "MA", "United States", "9686"])?;
10 wtr.write_record(&["Northbridge", "MA", "United States", "14061"])?;
11 wtr.flush()?;
12 Ok(())
13 }
14
main()15 fn main() {
16 if let Err(err) = example() {
17 println!("error running example: {}", err);
18 process::exit(1);
19 }
20 }
21