This repository was archived by the owner on Mar 25, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 180
Support tags on sequences and mappings #147
Comments
It seems that tags don't work on numbers either. Modified from #[test]
fn test_enum_tag() {
#[derive(Deserialize, PartialEq, Debug)]
enum E {
A(String),
B(String),
C(f32), // <-- this is new
}
#[derive(Deserialize, PartialEq, Debug)]
struct Data {
a: E,
b: E,
c: E
}
let yaml = unindent(
"
---
a: !A foo
b: !B bar
c: !C 1.0",
);
let expected = Data {
a: E::A("foo".into()),
b: E::B("bar".into()),
c: E::C(1.0),
};
test_de(&yaml, &expected);
}
|
This was referenced Nov 2, 2021
Closed
Fixed in 0.9. |
Is there a supported way such that the former workaround of using e.g. Thanks for all your hard work! |
Just in case someone finds their way here from googling errors like I did, I wanted to update that i answered my own question by looking at another issue and you can uses singleton maps https://docs.rs/serde_yaml/0.9.4/serde_yaml/with/singleton_map/index.html Thanks again for all the hard work! |
Repository owner
locked and limited conversation to collaborators
Aug 4, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
See https://users.rust-lang.org/t/help-using-serde-yaml-to-deserialize-value-with-very-many-possible-types/37058
Currently, this enum type is capable of using tags in place of singleton mappings to disambiguate between its String variants:
But it cannot use tags for the sequence-type variants: (it can only use singleton mappings)
A solution to this would appear to be blocked on chyh1990/yaml-rust#147, as the upstream parsing library currently does not emit tags in its
SequenceStart
orMappingStart
events.Aside: I find it rather amusing how both of these issues ended up being number 147. 😄
The text was updated successfully, but these errors were encountered: