1 use std
::{error::Error, io, process}
;
3 fn run() -> Result
<(), Box
<dyn Error
>> {
4 let mut wtr
= csv
::Writer
::from_writer(io
::stdout());
6 // We still need to write headers manually.
15 // But now we can write records by providing a normal Rust value.
17 // Note that the odd `None::<u64>` syntax is required because `None` on
18 // its own doesn't have a concrete type, but Serde needs a concrete type
19 // in order to serialize it. That is, `None` has type `Option<T>` but
20 // `None::<u64>` has type `Option<u64>`.
28 wtr
.serialize(("Kenai", "AK", Some(7610), 60.5544444, -151.2583333))?
;
29 wtr
.serialize(("Oakman", "AL", None
::<u64>, 33.7133333, -87.3886111))?
;
36 if let Err(err
) = run() {