Files
rk35xx-android14/external/rust/crates/csv/examples/cookbook-write-basic.rs
T
hmz007 36ed224bac Rockchip Anroid14_SDK 20240628-rkr5 (2556df1a)
Signed-off-by: hmz007 <hmz007@gmail.com>
Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
2024-10-29 18:12:02 +08:00

21 lines
629 B
Rust

use std::{error::Error, io, process};
fn example() -> Result<(), Box<dyn Error>> {
let mut wtr = csv::Writer::from_writer(io::stdout());
// When writing records without Serde, the header record is written just
// like any other record.
wtr.write_record(&["city", "region", "country", "population"])?;
wtr.write_record(&["Southborough", "MA", "United States", "9686"])?;
wtr.write_record(&["Northbridge", "MA", "United States", "14061"])?;
wtr.flush()?;
Ok(())
}
fn main() {
if let Err(err) = example() {
println!("error running example: {}", err);
process::exit(1);
}
}