config-rs
config-rs copied to clipboard
Incorrect serialize/deserialize struct with empty Vec field
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.
Is this still true for the latest release?
Is this still true for the latest release?
Yes, this is still true for 0.11.