Enum wasmer_wasix::syscalls::Infallible
1.34.0 · source · pub(crate) enum Infallible {}
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)) // Never returns `Err`
}
}
§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 impl
s will start to overlap
and therefore will be disallowed by the language’s trait coherence rules.
Trait Implementations§
1.34.0 · source§impl Clone for Infallible
impl Clone for Infallible
source§fn clone(&self) -> Infallible
fn clone(&self) -> Infallible
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Context<T, Infallible> for Option<T>
impl<T> Context<T, Infallible> for Option<T>
use anyhow::{Context, Result};
fn maybe_get() -> Option<T> {
...
}
fn demo() -> Result<()> {
let t = maybe_get().context("there is no T")?;
...
}
1.34.0 · source§impl Debug for Infallible
impl Debug for Infallible
1.34.0 · source§impl Display for Infallible
impl Display for Infallible
1.8.0 · source§impl Error for Infallible
impl Error for Infallible
source§fn description(&self) -> &str
fn description(&self) -> &str
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.34.0 · source§impl From<!> for Infallible
impl From<!> for Infallible
source§fn from(x: !) -> Infallible
fn from(x: !) -> Infallible
1.44.0 · source§impl Hash for Infallible
impl Hash for Infallible
1.34.0 · source§impl Ord for Infallible
impl Ord for Infallible
source§fn cmp(&self, _other: &Infallible) -> Ordering
fn cmp(&self, _other: &Infallible) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.34.0 · source§impl PartialEq for Infallible
impl PartialEq for Infallible
source§fn eq(&self, _: &Infallible) -> bool
fn eq(&self, _: &Infallible) -> bool
self
and other
values to be equal, and is used
by ==
.1.34.0 · source§impl PartialOrd for Infallible
impl PartialOrd for Infallible
source§fn partial_cmp(&self, _other: &Infallible) -> Option<Ordering>
fn partial_cmp(&self, _other: &Infallible) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more1.61.0 · source§impl Termination for Infallible
impl Termination for Infallible
§impl Trace for Infallible
impl Trace for Infallible
§impl WasmTypeList for Infallible
impl WasmTypeList for Infallible
§type CStruct = Infallible
type CStruct = Infallible
§unsafe fn from_array(
_: &mut impl AsStoreMut,
_: <Infallible as WasmTypeList>::Array,
) -> Infallible
unsafe fn from_array( _: &mut impl AsStoreMut, _: <Infallible as WasmTypeList>::Array, ) -> Infallible
Self
based on an array of values. Read more§unsafe fn from_slice(
_: &mut impl AsStoreMut,
_: &[RawValue],
) -> Result<Infallible, TryFromSliceError>
unsafe fn from_slice( _: &mut impl AsStoreMut, _: &[RawValue], ) -> Result<Infallible, TryFromSliceError>
Self
based on a slice of values. Read more§unsafe fn into_array(
self,
_: &mut impl AsStoreMut,
) -> <Infallible as WasmTypeList>::Array
unsafe fn into_array( self, _: &mut impl AsStoreMut, ) -> <Infallible as WasmTypeList>::Array
Array
from a tuple
(list) of values. Read more§fn empty_array() -> <Infallible as WasmTypeList>::Array
fn empty_array() -> <Infallible as WasmTypeList>::Array
Array
that
will hold a tuple (list) of values, usually to hold the
returned values of a WebAssembly function call.§unsafe fn from_c_struct(
_: &mut impl AsStoreMut,
self_: <Infallible as WasmTypeList>::CStruct,
) -> Infallible
unsafe fn from_c_struct( _: &mut impl AsStoreMut, self_: <Infallible as WasmTypeList>::CStruct, ) -> Infallible
CStruct
. Read more§unsafe fn into_c_struct(
self,
_: &mut impl AsStoreMut,
) -> <Infallible as WasmTypeList>::CStruct
unsafe fn into_c_struct( self, _: &mut impl AsStoreMut, ) -> <Infallible as WasmTypeList>::CStruct
CStruct
from a
tuple (list) of values. Read more§unsafe fn write_c_struct_to_ptr(
_: <Infallible as WasmTypeList>::CStruct,
_: *mut RawValue,
)
unsafe fn write_c_struct_to_ptr( _: <Infallible as WasmTypeList>::CStruct, _: *mut RawValue, )
RawValue
. Read more§fn wasm_types() -> &'static [Type]
fn wasm_types() -> &'static [Type]
impl Copy for Infallible
impl Eq for Infallible
impl Never for Infallible
impl RmpReadErr for Infallible
impl RmpWriteErr for Infallible
Auto Trait Implementations§
impl Freeze for Infallible
impl RefUnwindSafe for Infallible
impl Send for Infallible
impl Sync for Infallible
impl Unpin for Infallible
impl UnwindSafe for Infallible
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more