Enum Infallible Copy item path 1.34.0 · Source pub enum Infallible {}This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Expand description The error type for errors that can never happen.
Since this enum has no variant, a value of this type can never actually exist.
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.
ⓘ 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)) }
}§ Future compatibility
This enum has the same role as the ! “never” type ,
which is unstable in this version of Rust.
When ! is stabilized, we plan to make Infallible a type alias to it:
ⓘ pub type Infallible = !;
… and eventually deprecate Infallible.
However there is one case where ! syntax can be used
before ! is stabilized as a full-fledged type: in the position of a function’s return type.
Specifically, it is possible to have implementations for two different function pointer types:
trait MyTrait {}
impl MyTrait for fn () -> ! {}
impl MyTrait for fn () -> std::convert::Infallible {}
With Infallible being an enum, this code is valid.
However when Infallible becomes an alias for the never type,
the two impls will start to overlap
and therefore will be disallowed by the language’s trait coherence rules.
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Performs copy-assignment from
source.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Formats the value using the given formatter.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Formats the value using the given formatter.
Read more Returns the lower-level source of this error, if any.
Read more 👎 Deprecated since 1.42.0: use the Display impl or to_string()
👎 Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
🔬 This is a nightly-only experimental API. (error_generic_member_access #99301 ) Provides type-based access to context intended for error reports.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Converts to this type from the input type.
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Converts to this type from the input type.
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Converts to this type from the input type.
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Compares and returns the maximum of two values.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Compares and returns the minimum of two values.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Restrict a value to a certain interval.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
This method returns an ordering between
self and
other values if one exists.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Tests less than (for
self and
other) and is used by the
< operator.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Tests greater than (for
self and
other) and is used by the
>
operator.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Immutably borrows from an owned value.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit #126799 ) This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Performs copy-assignment from
self to
dest.
Read more This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Converts to this type from the input type.
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Returns the argument unchanged.
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The type returned in the event of a conversion error.
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Performs the conversion.
The type returned in the event of a conversion error.
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B) .
Performs the conversion.