From b0bc8e35946d5937f9af73804518a7ac8b5bf7ae Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Thu, 28 Jan 2016 11:49:36 -0800 Subject: [PATCH] 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. --- serde/src/de/impls.rs | 3 ++- serde/src/de/mod.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index a6240622..4d8b95f8 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1004,7 +1004,8 @@ impl Deserialize for IgnoredAny { } } - deserializer.deserialize(IgnoredAnyVisitor) + // TODO maybe not necessary with impl specialization + deserializer.deserialize_ignored_any(IgnoredAnyVisitor) } } diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index e76ab812..b06a4ce3 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -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(&mut self, visitor: V) -> Result + where V: Visitor + { + self.deserialize(visitor) + } + /// Specify a format string for the deserializer. /// /// The deserializer format is used to determine which format