-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Is there an existing issue for this?
- I have searched the existing issues
Code of Conduct
- I agree to follow this project's Code of Conduct
Current Behaviour
The following code fails to deserialize Some(None):
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Foo(Option<Option<bool>>);
fn main() {
for o in [None, Some(None), Some(Some(true)), Some(Some(false))] {
let o = Foo(o);
let mut ser = vec![];
ciborium::into_writer(&o, &mut ser).unwrap();
let o2: Foo = ciborium::from_reader(&mut ser.as_slice()).unwrap();
if o != o2 {
println!("error: {o:?} deserialized as {o2:?}");
}
}
}Running the above code prints:
error: Foo(Some(None)) deserialized as Foo(None)
Expected Behaviour
I expected Some(None) to round-trip through ciborium as Some(None) (i.e. the above program to output nothing). We are investigating ciborium for types that use deserialize_any(), and inability to deserialize nested options is an issue.
I control the code that does the (de-)serialization, so if it's a matter of setting up some configuration, that'd work for me.
Environment Information
$ uname -a
Linux snijeg 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ enarx --version
zsh: command not found: enarx
Steps To Reproduce
Run the included code, and observe the result.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
New