1 use std
::{error::Error, io, process}
;
5 #[derive(Debug, Serialize)]
10 population
: Option
<u64>,
13 fn example() -> Result
<(), Box
<dyn Error
>> {
14 let mut wtr
= csv
::Writer
::from_writer(io
::stdout());
16 // When writing records with Serde using structs, the header row is written
18 wtr
.serialize(Record
{
19 city
: "Southborough".to_string(),
20 region
: "MA".to_string(),
21 country
: "United States".to_string(),
22 population
: Some(9686),
24 wtr
.serialize(Record
{
25 city
: "Northbridge".to_string(),
26 region
: "MA".to_string(),
27 country
: "United States".to_string(),
28 population
: Some(14061),
35 if let Err(err
) = example() {
36 println
!("error running example: {}", err
);