I am trying to deserialize a large CSV using csv crate file into an struct like:
#[derive(Debug, Deserialize)]
struct Record {
record_id: u32,
period: [char; 6],
}
(Note: There are many more fields and this is a contrived example.)
The purpose of using a [char;6]
instead of String
is reduction in memory used by the parsed structure. But I am getting an error like:
DeserializeError {
field: Some(43),
kind: Message("expected single character but got 6 characters in \'A1B2C3\'")
}
- How can I fix this?
- Is there really a memory benefit in using
[char; 6]
v/sString
(since the code does not compile, I cannot benchmark this myself.)