Open XX opened 5 years ago
I wrote the following test:
#[test] fn test_empty_seq() { #[derive(Debug, Serialize, Deserialize, PartialEq)] struct Test { int: u32, seq: Vec<String>, } let test = Test { int: 1, seq: vec![], }; let config = Config::try_from(&test).unwrap(); let actual: Test = config.try_into().unwrap(); assert_eq!(test, actual); }
After running it displays this error:
thread 'ser::test::test_empty_seq' panicked at 'called `Result::unwrap()` on an `Err` value: missing field `seq`', src/libcore/result.rs:997:5
When I add the #[serde(default)] attribute to the seq field, it is successful, but if the struct contains only an empty-vec-field, it does not help.
#[serde(default)]
seq
Is this still true for the latest release?
Yes, this is still true for 0.11.
Is this still an issue?
I think I've just bumped into it with Hashmasps
I wrote the following test:
After running it displays this error:
When I add the
#[serde(default)]
attribute to theseq
field, it is successful, but if the struct contains only an empty-vec-field, it does not help.