-
-
Notifications
You must be signed in to change notification settings - Fork 873
Open
Description
Custom deserialization code seems to turn very complex quickly, mostly because of all the visitors. I wonder, what was the original reason this API was chosen? Is there a reason the crate decided not to expose "simpler" APIs, like in the example below?
enum Value {
Name(String),
Age(u32),
}
struct Student(HashMap<bool, Value>);
impl<'de> Deserialize<'de> for Student {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>
{
#[derive(DeserializeOrEnumerate)]
enum Field { Name, Age };
let name = None;
let age = None;
while let Some(field) = deserializer.deserialize_field<Field>()? {
match field {
// filling those `Option<T>` vars...
}
}
Self { /* ... */ }
}
}Metadata
Metadata
Assignees
Labels
No labels