-
Notifications
You must be signed in to change notification settings - Fork 606
Closed
Labels
Description
An IntoDeserializer
impl would provide a way to deserialize from these types while constructing exactly the right error type on failure, rather than constructing a serde_json::Error
and mapping it to a custom error of the target type through its Display
impl.
fn f<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where
T: Deserialize<'de>,
D: Deserializer<'de>,
{
let mut v = Value::deserialize(deserializer)?;
/* some manipulation of v */
T::deserialize(v).map_err(serde::de::Error::custom)
}
- T::deserialize(v).map_err(serde::de::Error::custom)
+ T::deserialize(v.into_deserializer())