• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use std::error::Error;
2 use std::io;
3 use std::process;
4 
run() -> Result<(), Box<dyn Error>>5 fn run() -> Result<(), Box<dyn Error>> {
6     let mut wtr = csv::WriterBuilder::new()
7         .delimiter(b'\t')
8         .quote_style(csv::QuoteStyle::NonNumeric)
9         .from_writer(io::stdout());
10 
11     wtr.write_record(&[
12         "City",
13         "State",
14         "Population",
15         "Latitude",
16         "Longitude",
17     ])?;
18     wtr.write_record(&[
19         "Davidsons Landing",
20         "AK",
21         "",
22         "65.2419444",
23         "-165.2716667",
24     ])?;
25     wtr.write_record(&["Kenai", "AK", "7610", "60.5544444", "-151.2583333"])?;
26     wtr.write_record(&["Oakman", "AL", "", "33.7133333", "-87.3886111"])?;
27 
28     wtr.flush()?;
29     Ok(())
30 }
31 
main()32 fn main() {
33     if let Err(err) = run() {
34         println!("{}", err);
35         process::exit(1);
36     }
37 }
38