A fresh new install of Ubuntu, VS Code (1.85.2) with plugins Rust-analyzer (0.3.1815) & CodeLLDB (1.10.0).
A new empty crate with just main.rs
. Rust analyzer shows me error in #[derive(Deserialize)
, whist cargo c
shows no such error and runs the program normally. What is going on?
Cargo.toml
:
[package]
name = "heatmap"
version = "0.1.0"
edition = "2021"
[dependencies]
geo = "0.27"
serde = {version = "1", features = ["derive"] }
serde_json = "1.0"
csv = "1.3"
main.rs
:
use std::{collections::HashMap, error::Error};
use csv::Reader;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct CsvRow {
lon: f32,
lat: f32
}
fn main() -> Result<(), Box<dyn Error>> {
let mut rd = Reader::from_path("input_path.csv")?;
let hm: HashMap<(i32, i32), u32> = HashMap::new();
for r in rd.deserialize() {
let r: CsvRow = r?;
let x = (r.lon, r.lat);
}
Ok(())
}
When I run main.rs in VS Code, the error disappears, but as soon as I press Ctrl+S
, it reappears.
Here's the error. What's going on, how to fix this?