# [−][src]Enum serde::de::Unexpected

    pub enum Unexpected<'a> {
        Bool(bool),
        Unsigned(u64),
        Signed(i64),
        Float(f64),
        Char(char),
        Str(&'a str),
        Bytes(&'a [u8]),
        Unit,
        Option,
        NewtypeStruct,
        Seq,
        Map,
        Enum,
        UnitVariant,
        NewtypeVariant,
        TupleVariant,
        StructVariant,
        Other(&'a str),
    }

`Unexpected` represents an unexpected invocation of any one of the `Visitor` trait methods.

This is used as an argument to the `invalid_type`, `invalid_value`, and `invalid_length` methods of the `Error` trait to build error messages.

    # use std::fmt;
    #
    # use serde::de::{self, Unexpected, Visitor};
    #
    # struct Example;
    #
    # impl<'de> Visitor<'de> for Example {
    #     type Value = ();
    #
    #     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
    #         write!(formatter, "definitely not a boolean")
    #     }
    #
    fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
    where
        E: de::Error,
    {
        Err(de::Error::invalid_type(Unexpected::Bool(v), &self))
    }
    # }

## Variants

`Bool(bool)`

The input contained a boolean value that was not expected.

`Unsigned(u64)`

The input contained an unsigned integer `u8`, `u16`, `u32` or `u64` that was not expected.

`Signed(i64)`

The input contained a signed integer `i8`, `i16`, `i32` or `i64` that was not expected.

`Float(f64)`

The input contained a floating point `f32` or `f64` that was not expected.

`Char(char)`

The input contained a `char` that was not expected.

`Str(&'a str)`

The input contained a `&str` or `String` that was not expected.

`Bytes(&'a [u8])`

The input contained a `&[u8]` or `Vec<u8>` that was not expected.

`Unit`

The input contained a unit `()` that was not expected.

`Option`

The input contained an `Option<T>` that was not expected.

`NewtypeStruct`

The input contained a newtype struct that was not expected.

`Seq`

The input contained a sequence that was not expected.

`Map`

The input contained a map that was not expected.

`Enum`

The input contained an enum that was not expected.

`UnitVariant`

The input contained a unit variant that was not expected.

`NewtypeVariant`

The input contained a newtype variant that was not expected.

`TupleVariant`

The input contained a tuple variant that was not expected.

`StructVariant`

The input contained a struct variant that was not expected.

`Other(&'a str)`

A message stating what uncategorized thing the input contained that was not expected.

The message should be a noun or noun phrase, not capitalized and without a period. An example message is "unoriginal superhero".

## Trait Implementations

### `impl<'a> Clone for Unexpected<'a>`[src]

#### `fn clone(&self) -> Unexpected<'a>`[src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl<'a> PartialEq<Unexpected<'a>> for Unexpected<'a>`[src]

#### `fn eq(&self, other: &Unexpected<'a>) -> bool`[src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `fn ne(&self, other: &Unexpected<'a>) -> bool`[src]

This method tests for `!=`.

### `impl<'a> Copy for Unexpected<'a>`[src]

### `impl<'a> Debug for Unexpected<'a>`[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`[src]

Formats the value using the given formatter. Read more

### `impl<'a> Display for Unexpected<'a>`[src]

#### `fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error>`[src]

Formats the value using the given formatter. Read more

## Auto Trait Implementations

### `impl<'a> Send for Unexpected<'a>`

### `impl<'a> Unpin for Unexpected<'a>`

### `impl<'a> Sync for Unexpected<'a>`

### `impl<'a> UnwindSafe for Unexpected<'a>`

### `impl<'a> RefUnwindSafe for Unexpected<'a>`

## Blanket Implementations

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `fn to_owned(&self) -> T`[src]

Creates owned data from borrowed data, usually by cloning. Read more

#### `fn clone_into(&self, target: &mut T)`[src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `fn into(self) -> U`[src]

Performs the conversion.

### `impl<T> From<T> for T`[src]

#### `fn from(t: T) -> T`[src]

Performs the conversion.

### `impl<T> ToString for T where
T: Display + ?Sized,` [src]

#### `default fn to_string(&self) -> String`[src]

Converts the given value to a `String`. Read more

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

####
ⓘImportant traits for &'_ mut W

### Important traits for &'_ mut W

`impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;`
`fn borrow_mut(&mut self) -> &mut T`[src]

Mutably borrows from an owned value. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

####
ⓘImportant traits for &'_ mut W

### Important traits for &'_ mut W

`impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;`
`fn borrow(&self) -> &T`[src]

Immutably borrows from an owned value. Read more

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)