mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-25 15:07:56 +00:00
feat(de): Support hinting for IgnoredAny
IgnoredAny was calling `deserializer.deserialize` directly which is guaranteed to Error for certain formats like redis and bincode. This adds a `deserialize_ignored_any` method to hint to such implementations.
This commit is contained in:
@@ -1004,7 +1004,8 @@ impl Deserialize for IgnoredAny {
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize(IgnoredAnyVisitor)
|
||||
// TODO maybe not necessary with impl specialization
|
||||
deserializer.deserialize_ignored_any(IgnoredAnyVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -416,6 +416,15 @@ pub trait Deserializer {
|
||||
self.deserialize(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type needs to deserialize a value whose type
|
||||
/// doesn't matter because it is ignored.
|
||||
#[inline]
|
||||
fn deserialize_ignored_any<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor
|
||||
{
|
||||
self.deserialize(visitor)
|
||||
}
|
||||
|
||||
/// Specify a format string for the deserializer.
|
||||
///
|
||||
/// The deserializer format is used to determine which format
|
||||
|
||||
Reference in New Issue
Block a user