mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 15:25:38 +00:00
Unignore VariantVisitor::visit_unit example
This commit is contained in:
parent
7ef80a845d
commit
9d73271db2
@ -1476,12 +1476,32 @@ pub trait VariantVisitor<'de>: Sized {
|
|||||||
/// If the data contains a different type of variant, the following
|
/// If the data contains a different type of variant, the following
|
||||||
/// `invalid_type` error should be constructed:
|
/// `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> {
|
/// fn visit_unit(self) -> Result<(), Self::Error> {
|
||||||
/// // What the data actually contained; suppose it is a tuple variant.
|
/// // What the data actually contained; suppose it is a tuple variant.
|
||||||
/// let unexp = Unexpected::TupleVariant;
|
/// let unexp = Unexpected::TupleVariant;
|
||||||
/// Err(de::Error::invalid_type(unexp, &"unit variant"))
|
/// Err(de::Error::invalid_type(unexp, &"unit variant"))
|
||||||
/// }
|
/// }
|
||||||
|
/// #
|
||||||
|
/// # fn visit_newtype_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
|
||||||
|
/// # where T: DeserializeSeed<'de>
|
||||||
|
/// # { unimplemented!() }
|
||||||
|
/// #
|
||||||
|
/// # fn visit_tuple<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
|
||||||
|
/// # where V: Visitor<'de>
|
||||||
|
/// # { unimplemented!() }
|
||||||
|
/// #
|
||||||
|
/// # fn visit_struct<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
|
||||||
|
/// # where V: Visitor<'de>
|
||||||
|
/// # { unimplemented!() }
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
fn visit_unit(self) -> Result<(), Self::Error>;
|
fn visit_unit(self) -> Result<(), Self::Error>;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user