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
{{ message }}
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
let x = Value::Tagged(Box::new(TaggedValue{tag:Tag::new("hello"),value:Value::Null,}));assert!(!x.is_null());// fails
x is treated as Null despite being a TaggedValue. This causes issues when dealing with enums that have optional values like the following:
#[derive(Serialize,Deserialize,Debug)]enumTestEnum{V(Option<String>),}#[derive(Serialize,Deserialize,Debug)]structTestStruct{f:Option<TestEnum>,}let x = TestStruct{f:Some(TestEnum::V(None)),};let y = serde_yaml::to_string(&x).unwrap();// serialized to `f: !V null`let v:Value = serde_yaml::from_str(&y).unwrap();assert_eq!(x.f.is_none(), v.get("f").unwrap().is_null());// fails
This makes it appear as if x.f is None, when in reality it is Some(TestEnum::V(None)). This didn't use to be the case and in version 0.8.0 both the above examples would pass. This is an obvious enough change that I'm guessing it must be intended, but I feel like the current behavior is severely misleading and, at the very least, a warning should be given in the documentation of is_null
The text was updated successfully, but these errors were encountered:
# for freeto subscribe to this conversation on GitHub.
Already have an account?
#.
the following code shows the issue
x
is treated asNull
despite being aTaggedValue
. This causes issues when dealing with enums that have optional values like the following:This makes it appear as if
x.f
isNone
, when in reality it isSome(TestEnum::V(None))
. This didn't use to be the case and in version0.8.0
both the above examples would pass. This is an obvious enough change that I'm guessing it must be intended, but I feel like the current behavior is severely misleading and, at the very least, a warning should be given in the documentation ofis_null
The text was updated successfully, but these errors were encountered: