Skip to content
Discussion options

You must be logged in to vote

In the future, for something like this, it's really important to provide an MRE. Otherwise I have to spend my own time trying to guess at what it is you're asking about. I came up with this. Here is my main.rs:

#[derive(Debug, serde::Deserilize)]
struct Record {
    foo: i32,
    bar: i32,
    quux: i32,
    baz: i32,
}

fn main() -> anyhow::Result<()> {
    let data = "\
foo,bar,quux,bar,baz
1,2,3,4,5
";
    let mut rdr = csv::Reader::from_reader(data.as_bytes());
    for result in rdr.deserialize() {
        let record: Record = result?;
        dbg!(&record);
    }

    Ok(())
}

With this Cargo.toml:

[package]
publish = false
name = "csv-duplicate-fields"
version = "0.1.0"
edition = "2024

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #407 on October 17, 2025 13:08.