# 1.34.0[−][src]Type Definition std::convert::Infallible

    type Infallible = !;

A type alias for the `!` “never” type.

`Infallible` represents types of errors that can never happen since `!` has no valid values. This can be useful for generic APIs that use `Result` and parameterize the error type, to indicate that the result is always `Ok`.

For example, the `TryFrom` trait (conversion that returns a `Result`) has a blanket implementation for all types where a reverse `Into` implementation exists.

ⓘThis example is not tested

    impl<T, U> TryFrom<U> for T where U: Into<T> {
        type Error = Infallible;

        fn try_from(value: U) -> Result<Self, Infallible> {
            Ok(U::into(value))  // Never returns `Err`
        }
    }Run

# Eventual deprecation

Previously, `Infallible` was defined as `enum Infallible {}`. Now that it is merely a type alias to `!`, we will eventually deprecate `Infallible`.