Repository: serde-rs/serde
File: serde/src/de/mod.rs (Rust)

Code before:
    fn visit<V>(&mut self, visitor: V) -> Result<Self::Value, V::Error>
        where V: VariantVisitor;
}

///////////////////////////////////////////////////////////////////////////////

/// `VariantVisitor` is a visitor that is created by the `Deserializer` and passed to the
/// `Deserialize` in order to deserialize a specific enum variant.
pub trait VariantVisitor {
    type Error: Error;

    /// `visit_variant` is called to identify which variant to deserialize.
    fn visit_variant<V>(&mut self) -> Result<V, Self::Error>
        where V: Deserialize;

    /// `visit_unit` is called when deserializing a variant with no values.
    fn visit_unit(&mut self) -> Result<(), Self::Error> {
        Err(Error::syntax_error())
    }

    /// `visit_simple` is called when deserializing a variant with a single value.
    fn visit_simple<T: Deserialize>(&mut self) -> Result<T, Self::Error> {
        Err(Error::syntax_error())
    }

    /// `visit_seq` is called when deserializing a tuple-like variant.
    fn visit_seq<V>(&mut self, _visitor: V) -> Result<V::Value, Self::Error>
        where V: Visitor
    {
        Err(Error::syntax_error())
    }

    /// `visit_map` is called when deserializing a struct-like variant.
    fn visit_map<V>(&mut self, _visitor: V) -> Result<V::Value, Self::Error>
        where V: Visitor
    {
        Err(Error::syntax_error())
    }
}

impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
    type Error = T::Error;

    fn visit_variant<V>(&mut self) -> Result<V, T::Error>
        where V: Deserialize
    {
        (**self).visit_variant()
    }

    fn visit_unit(&mut self) -> Result<(), T::Error> {
        (**self).visit_unit()

Review comment (suggestion):
instead of erroring this could try to do a `visit_seq` by default to get back the original behavior for downstream `Deserializer` implementors


Code after:
pub trait EnumVisitor {
    type Value;

    fn visit<V>(&mut self, visitor: V) -> Result<Self::Value, V::Error>
        where V: VariantVisitor;
}

///////////////////////////////////////////////////////////////////////////////

/// `VariantVisitor` is a visitor that is created by the `Deserializer` and passed to the
/// `Deserialize` in order to deserialize a specific enum variant.
pub trait VariantVisitor {
    type Error: Error;

    /// `visit_variant` is called to identify which variant to deserialize.
    fn visit_variant<V>(&mut self) -> Result<V, Self::Error>
        where V: Deserialize;

    /// `visit_unit` is called when deserializing a variant with no values.
    fn visit_unit(&mut self) -> Result<(), Self::Error> {
        Err(Error::syntax_error())
    }

    /// `visit_simple` is called when deserializing a variant with a single value.
    fn visit_simple<T: Deserialize>(&mut self) -> Result<T, Self::Error> {
        Err(Error::syntax_error())
    }

    /// `visit_seq` is called when deserializing a tuple-like variant.
    fn visit_seq<V>(&mut self, _visitor: V) -> Result<V::Value, Self::Error>
        where V: Visitor
    {
        Err(Error::syntax_error())
    }

    /// `visit_map` is called when deserializing a struct-like variant.
    fn visit_map<V>(&mut self,
                    _fields: &'static [&'static str],
                    _visitor: V) -> Result<V::Value, Self::Error>
        where V: Visitor
    {
        Err(Error::syntax_error())
    }
}

impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
    type Error = T::Error;

    fn visit_variant<V>(&mut self) -> Result<V, T::Error>
        where V: Deserialize
    {