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