Enum core_extensions::Void
source · [−]pub enum Void {}
void
only.Expand description
Type for impossible situations.
Use this as a type parameter to enums to make the variants that use it unconstructible.
Interaction with unsafe code
It is only valid to convert to Void from other Void-like types, it is undefined behavior to convert from any constructible type, even if zero-sized.
Example, infinite loop which only returns on error.
use core_extensions::{ResultLikeExt, Void};
#[derive(Debug,PartialEq)]
enum Error<T>{
InvalidItem(T),
IteratorWasntInfinite,
}
fn reading_numbers<I>(i: I) -> Result<Void, Error<usize>>
where I: IntoIterator<Item = usize>
{
for elem in i{
if elem == 0 { return Err(Error::InvalidItem(elem)) }
println!("{}", elem);
}
Err(Error::IteratorWasntInfinite)
}
assert_eq!(reading_numbers(1..100).into_error(), Error::IteratorWasntInfinite);
assert_eq!(reading_numbers(0..).into_error(), Error::InvalidItem(0));
Implementations
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Void
impl<'de> Deserialize<'de> for Void
This impl is only enabled if the “serde_” feature is enabled.
This always Returns an Err(D::Error::custom(DeserializeVoidError))
.
sourcefn deserialize<D>(_: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(_: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<Infallible> for Void
impl From<Infallible> for Void
There’s also a impl From<Void> for std_::convert::Infallible
impl
that’s not appearing in the docs for some reason.
sourcefn from(this: Infallible) -> Self
fn from(this: Infallible) -> Self
Converts to this type from the input type.
sourceimpl From<Void> for Infallible
impl From<Void> for Infallible
sourceimpl Ord for Void
impl Ord for Void
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: ?Sized> PartialEq<T> for Void
impl<T: ?Sized> PartialEq<T> for Void
sourceimpl<T: ?Sized> PartialOrd<T> for Void
impl<T: ?Sized> PartialOrd<T> for Void
sourcefn partial_cmp(&self, _: &T) -> Option<Ordering>
fn partial_cmp(&self, _: &T) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Void
impl Eq for Void
Auto Trait Implementations
impl RefUnwindSafe for Void
impl Send for Void
impl Sync for Void
impl Unpin for Void
impl UnwindSafe for Void
Blanket Implementations
sourceimpl<T> AsPhantomData for T where
T: ?Sized,
impl<T> AsPhantomData for T where
T: ?Sized,
sourcefn as_phantom(&self) -> PhantomData<Self>
fn as_phantom(&self) -> PhantomData<Self>
phantom
only.Gets a PhantomData<Self>
. Read more
sourcefn as_phantom_covariant(&self) -> PhantomData<fn() -> Self>
fn as_phantom_covariant(&self) -> PhantomData<fn() -> Self>
phantom
only.Gets a PhantomData<fn() -> Self>
, a covariant PhantomData
.
sourcefn as_phantom_contra(&self) -> PhantomData<fn(_: Self)>
fn as_phantom_contra(&self) -> PhantomData<fn(_: Self)>
phantom
only.Gets a PhantomData<fn(Self)>
, a contravariant PhantomData
.
sourcefn as_phantom_invariant(&self) -> PhantomData<fn(_: Self) -> Self>
fn as_phantom_invariant(&self) -> PhantomData<fn(_: Self) -> Self>
phantom
only.Gets a PhantomData<fn(Self) -> Self>
, an invariant PhantomData
.
sourceconst PHANTOM: PhantomData<Self> = PhantomData
const PHANTOM: PhantomData<Self> = PhantomData
phantom
only.Gets a PhantomData<Self>
. Read more
sourceconst PHANTOM_COVARIANT: PhantomData<fn() -> Self> = PhantomData
const PHANTOM_COVARIANT: PhantomData<fn() -> Self> = PhantomData
phantom
only.Constructs a PhantomData<fn() -> T>
, a covariant PhantomData
. Read more
sourceconst PHANTOM_CONTRA: PhantomData<fn(_: Self)> = PhantomData
const PHANTOM_CONTRA: PhantomData<fn(_: Self)> = PhantomData
phantom
only.Gets a PhantomData<fn(Self)>
, a contravariant PhantomData
. Read more
sourceconst PHANTOM_INVARIANT: PhantomData<fn(_: Self) -> Self> = PhantomData
const PHANTOM_INVARIANT: PhantomData<fn(_: Self) -> Self> = PhantomData
phantom
only.Gets a PhantomData<fn(Self) -> Self>
, an invariant PhantomData
. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallExt for T where
T: ?Sized,
impl<T> CallExt for T where
T: ?Sized,
sourcefn ref_call<P>(&self, params: P) -> Self::Returns where
Self: CallRef<P>,
fn ref_call<P>(&self, params: P) -> Self::Returns where
Self: CallRef<P>,
callable
only.For calling CallRef::ref_call_
,
with the ability to specify the types of the arguments.. Read more