BurntSushi / BurntSushi/rust-csv
Provide a way to serialize the header prefixed with a comment character
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
#### What version of the `csv` crate are you using?
1.1.6
#### Briefly describe the question, bug or feature request.
Serialize the header prefixed with a comment character (eg. '#')
#### Include a complete program demonstrating a problem.
```rust
use std::fs::File;
use std::io::Write;
use serde::Serialize;
#[derive(Debug, Clone, Serialize)]
pub struct Partition {
name: String,
#[serde(rename="type")]
partition_type: u32,
subtype: u32,
offset: u32,
size: u32,
flags: u32,
}
fn main() {
let partitions = vec![
Partition {
name: "test".to_owned(),
partition_type: 1,
subtype: 1,
offset: 1,
size: 1,
flags: 1,
},
Partition {
name: "test2".to_owned(),
partition_type: 1,
subtype: 1,
offset: 1,
size: 1,
flags: 1,
},
];
let mut wrt = csv::Writer::from_writer(std::io::stdout());
partitions.iter().for_each(|partition| wrt.serialize(partition).unwrap());
wrt.flush().unwrap();
}
```
#### What is the observed behavior of the code above?
`name,type,subtype,offset,size,flags`
#### What is the expected or desired behavior of the code above?
`#name,type,subtype,offset,size,flags`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.