blob: 199d94b1ba8e8e0662b6bd5e3476c6be51b9add1 [file] [log] [blame]
Jakub Koturc72d7202020-12-21 17:28:15 +01001use std::error::Error;
2use std::io;
3use std::process;
4
5fn 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
17fn main() {
18 if let Err(err) = example() {
19 println!("error running example: {}", err);
20 process::exit(1);
21 }
22}