I'm trying to use CSV and Serde in a project but ran into issues so I wanted to start with the rust book example, but I'm getting the following error when I try
My guess is I'm missing something in my cargo.toml, but I don't see a way to tell what it should be.
here's what I'm using
Cargo.toml:
[dependencies]
serde = "1.0.132"
csv = "1.1.6"
Error:
error: cannot find derive macro `Deserialize` in this scope
--> src\main.rs:67:10
|
67 | #[derive(Deserialize)]
| ^^^^^^^^^^^
|
Code Example from Rustbook:
use serde::Deserialize;
#[derive(Deserialize)]
struct Record {
year: u16,
make: String,
model: String,
description: String,
}
fn main() -> Result<(), csv::Error> {
let csv = "year,make,model,description
1948,Porsche,356,Luxury sports car
1967,Ford,Mustang fastback 1967,American car";
let mut reader = csv::Reader::from_reader(csv.as_bytes());
for record in reader.deserialize() {
let record: Record = record?;
println!(
"In {}, {} built the {} model. It is a {}.",
record.year,
record.make,
record.model,
record.description
);
}
Ok(())
}