diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index d83a5cd9..d8b860b2 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -1605,16 +1605,36 @@ pub trait VariantVisitor<'de>: Sized { /// If the data contains a different type of variant, the following /// `invalid_type` error should be constructed: /// - /// ```rust,ignore + /// ```rust + /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantVisitor, Unexpected}; + /// # + /// # struct X; + /// # + /// # impl<'de> VariantVisitor<'de> for X { + /// # type Error = value::Error; + /// # + /// # fn visit_unit(self) -> Result<(), Self::Error> { + /// # unimplemented!() + /// # } + /// # + /// # fn visit_newtype_seed(self, _: T) -> Result + /// # where T: DeserializeSeed<'de> + /// # { unimplemented!() } + /// # + /// # fn visit_tuple(self, _: usize, _: V) -> Result + /// # where V: Visitor<'de> + /// # { unimplemented!() } + /// # /// fn visit_struct(self, /// _fields: &'static [&'static str], /// _visitor: V) -> Result - /// where V: Visitor + /// where V: Visitor<'de> /// { /// // What the data actually contained; suppose it is a unit variant. /// let unexp = Unexpected::UnitVariant; - /// Err(Error::invalid_type(unexp, &"struct variant")) + /// Err(de::Error::invalid_type(unexp, &"struct variant")) /// } + /// # } /// ``` fn visit_struct(self, fields: &'static [&'static str],