A newbie question: what error is happening here? And how to work around it?
Here's the sketch that represents my problem with csv::Writer
. Replacing &[...]
with vec![...]
does not change the error.
extern crate csv;
use std::error::Error;
use csv::Writer;
fn main() -> Result<(), Box<dyn Error>>{
let mut wr = Writer::from_path("/tmp/mycsv.csv")?;
let id: i64 = 1231313122;
let lon: f64 = 12.4567789;
let lat: f64 = 34.567890;
wr.write_record(&["id", "lon", "lat"])?;
wr.write_record(&[id as f64, lon, lat])?;
//^^^^^^^^^^^^^^^^^^^^^^ the trait `AsRef<[u8]>` is not implemented for `f64`
Ok(())
}