BurntSushi / BurntSushi/rust-csv

Deserialize a field to an empty Vec<>

Open
#330 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2k
Forks
257
PR merge metrics
No merged PRs in 30d

Description

Hello, thank you for this crate, I use it a lot. (a lot, and out of just deserializing csv actually).

Thank you for taking the time to answer.

#### What version of the `csv` crate are you using?

1.2.2

#### Briefly describe the question, bug or feature request.

I wonder if it is possible to deserialize an empty vec.

#### Include a complete program demonstrating a problem.

Taking directly from the documentation [here](https://docs.rs/csv/latest/csv/struct.Reader.html#rules)
```
#[test]
fn example() -> Result<(), Box> {
let data = "foo";
let mut rdr = ReaderBuilder::new()
.has_headers(false)
.from_reader(data.as_bytes());
let mut iter = rdr.deserialize();

if let Some(result) = iter.next() {
let record: Row = result?;
assert_eq!(
record,
Row {
label: "foo".to_string(),
values: vec![],
}
);
Ok(())
}
}
```

#### What is the observed behavior of the code above?

I edited a little bit your example in the Rules section, because I am working on a case where the list can be empty.

#### What is the expected or desired behavior of the code above?

I would like to see a
```
Row {
label: "foo".to_string(),
values: vec![],
}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.