Briefly describe the question, bug or feature request.
I want to deserialize different rows of a CSV file differently depending on wether a field can be serialized into an enum or is empty, I tried using a #[serde(untagged)] enum for that, but although that produces the expected output when serializing, it does fail to deserialize it (and it's own output).
Include a complete program demonstrating a problem.
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 1.01s
Running `target/debug/playground`
[src/main.rs:40:9] record = Err(
Error(
Deserialize {
pos: Some(
Position {
byte: 8,
line: 2,
record: 1,
},
),
err: DeserializeError {
field: None,
kind: Message(
"data did not match any variant of untagged enum MaybeRecord",
),
},
},
),
)
thread 'main' panicked at src/main.rs:47:30:
called `Result::unwrap()` on an `Err` value: Error(Deserialize { pos: Some(Position { byte: 8, line: 2, record: 1 }), err: DeserializeError { field: None, kind: Message("data did not match any variant of untagged enum MaybeRecord") } })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Standard Output
----
name,ty
baz,
foo,One
----
What is the expected or desired behavior of the code above?
While stdout shows that serialization was successfull, deserializing that very output fails.
What version of the
csv
crate are you using?1.3.0
Briefly describe the question, bug or feature request.
I want to deserialize different rows of a CSV file differently depending on wether a field can be serialized into an enum or is empty, I tried using a
#[serde(untagged)]
enum for that, but although that produces the expected output when serializing, it does fail to deserialize it (and it's own output).Include a complete program demonstrating a problem.
Playground
What is the observed behavior of the code above?
Standard Error
Standard Output
What is the expected or desired behavior of the code above?
While stdout shows that serialization was successfull, deserializing that very output fails.