You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Briefly describe the question, bug or feature request.
When deserializing to a String field using serde, csv can handle a field containing 123.
However, when doing the same to a flattened field, csv can no longer deserialize 123 to the String field and I get the error:
Include a complete program demonstrating a problem.
use serde::Deserialize;#[allow(dead_code)]#[derive(Debug,Deserialize)]structInner{inner_str:String,}#[allow(dead_code)]#[derive(Debug,Deserialize)]structRow{str:String,#[serde(flatten)]inner:Inner,}fnmain(){let source = r#"str,inner_strA,A123,AA,123 "#.trim();letmut reader = csv::Reader::from_reader(source.as_bytes());for line in reader.deserialize::<Row>(){dbg!(&line);}}
This does indeed look like a bug. I don't know when I'll have time to look into it, so patches are welcome if you can find a fix yourself.
I'll note that the presence of serde(flatten) concerns me. IIRC, it required some hacky things to make it work and it may not have been done correctly.
I don't know. I don't know much about serde internals. I do know that the serde(flatten) thing is a bit of a tortured feature though. It's one of those things that folks don't have to actually use, but it affords some very nice conveniences. But it just doesn't work in all cases.
I won't have time to look into this any time soon I'm afraid.
What version of the
csv
crate are you using?1.3.0
Briefly describe the question, bug or feature request.
When deserializing to a
String
field using serde,csv
can handle a field containing123
.However, when doing the same to a flattened field,
csv
can no longer deserialize123
to theString
field and I get the error:Include a complete program demonstrating a problem.
What is the observed behavior of the code above?
Output:
What is the expected or desired behavior of the code above?
Output:
The text was updated successfully, but these errors were encountered: