Open
Description
Hello!
I have a newtype wrapper around a u64 like so:
#[derive(Debug, Hydrate, Reconcile)]
pub struct Item {
pub name: String,
pub date: Option<Date>,
}
#[derive(Debug, Hydrate, Reconcile)]
pub struct Date(u64);
When I attempt to hydrate
it from a doc with a value present for that key, I get the error unexpected uint
.
I think this is because Option::hydrate calls Date::hydrate_uint but the derive impl for a newtype struct only generates Hydrate::hydrate. Is there a better way to accomplish what I'm trying to do here?
And as a larger meta question, why isn't the Hydrate impl for Option simply something like this that handles both missing and explicitly null values?
Ok(match doc.get(obj, &prop)? {
Some((Scalar(v), _)) if *v == Null => None,
Some(_) => Some(T::hydrate(doc, obj, prop)?),
None => None,
})
Metadata
Metadata
Assignees
Labels
No labels
Activity