// Called when the type to deserialize is an enum, as opposed to a field in the type.
Called when the type to deserialize is an enum, as opposed to a field in the type.
Called when the type to deserialize is an enum as opposed to a field in the type .
fn deserialize_enum<V>(
        self,
        _name: &'static str,
        _variants: &'static [&'static str],
        visitor: V
    ) -> Result<V::Value, Error>
        where V: de::Visitor<'de>
    {
        let (value, name) = self.string_or_table()?;
        match value.e {
            E::String(val) => visitor.visit_enum(val.into_deserializer()),
            E::InlineTable(values) => {
                if values.len() != 1 {
                    Err(Error::from_kind(ErrorKind::Wanted {
                        expected: "exactly 1 element",
                        found: if values.is_empty() {
                            "zero elements"
                        } else {
                            "more than 1 element"
                        },
                    }))
                } else {
                    visitor.visit_enum(InlineTableDeserializer {
                        values: values.into_iter(),
                        next_value: None,
                    })
                }
            }
            E::DottedTable(_) => visitor.visit_enum(DottedTableDeserializer {
                name: name.expect("Expected table header to be passed."),
                value: value,
            }),
            e @ _ => Err(Error::from_kind(ErrorKind::Wanted {
                expected: "string or table",
                found: e.type_name(),
            })),
        }
    }
fn deserialize_enum < V > ( self , _name : & ' static str , _variants : & ' static [ & ' static str ] , visitor : V ) -> Result < V :: Value , Error > where V : de :: Visitor < ' de > { let ( value , name ) = self . string_or_table ( ) ? ; match value . e { E :: String ( val ) => visitor . visit_enum ( val . into_deserializer ( ) ) , E :: InlineTable ( values ) => { if values . len ( ) != 1 { Err ( Error :: from_kind ( ErrorKind :: Wanted { expected : " " , found : if values . is_empty ( ) { " " } else { " " } , } ) ) } else { visitor . visit_enum ( InlineTableDeserializer { values : values . into_iter ( ) , next_value : None , } ) } } E :: DottedTable ( _ ) => visitor . visit_enum ( DottedTableDeserializer { name : name . expect ( " " ) , value : value , } ) , e @ _ => Err ( Error :: from_kind ( ErrorKind :: Wanted { expected : " " , found : e . type_name ( ) , } ) ) , } }
Called when the type to deserialize is an enum, as opposed to a field in the type.
Called when the type to deserialize is an enum as opposed to a field in the type .
self
_name
&'static str
_variants
&'static [&'static str]
visitor
V