pub enum Void {}Available on crate feature
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§
Source§impl<'de> Deserialize<'de> for Void
This impl is only enabled if the “serde_” feature is enabled.
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)).
Source§fn 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
Source§impl Error for Void
impl Error for Void
Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
Source§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.
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.
Source§fn from(this: Infallible) -> Self
fn from(this: Infallible) -> Self
Converts to this type from the input type.
Source§impl From<Void> for Infallible
impl From<Void> for Infallible
Source§impl Ord for Void
impl Ord for Void
Source§impl<T: ?Sized> PartialOrd<T> for Void
impl<T: ?Sized> PartialOrd<T> for Void
impl Copy for Void
impl Eq for Void
Auto Trait Implementations§
impl Freeze for Void
impl RefUnwindSafe for Void
impl Send for Void
impl Sync for Void
impl Unpin for Void
impl UnwindSafe for Void
Blanket Implementations§
Source§impl<T> AsPhantomData for Twhere
T: ?Sized,
impl<T> AsPhantomData for Twhere
T: ?Sized,
Source§fn as_phantom(&self) -> PhantomData<Self>
fn as_phantom(&self) -> PhantomData<Self>
Available on crate feature
phantom only.Gets a
PhantomData<Self>. Read moreSource§fn as_phantom_covariant(&self) -> PhantomData<fn() -> Self>
fn as_phantom_covariant(&self) -> PhantomData<fn() -> Self>
Available on crate feature
phantom only.Gets a
PhantomData<fn() -> Self>, a covariant PhantomData.Source§fn as_phantom_contra(&self) -> PhantomData<fn(Self)>
fn as_phantom_contra(&self) -> PhantomData<fn(Self)>
Available on crate feature
phantom only.Gets a
PhantomData<fn(Self)>, a contravariant PhantomData.Source§fn as_phantom_invariant(&self) -> PhantomData<fn(Self) -> Self>
fn as_phantom_invariant(&self) -> PhantomData<fn(Self) -> Self>
Available on crate feature
phantom only.Gets a
PhantomData<fn(Self) -> Self>, an invariant PhantomData.Source§const PHANTOM: PhantomData<Self> = PhantomData
const PHANTOM: PhantomData<Self> = PhantomData
Available on crate feature
phantom only.Gets a
PhantomData<Self>. Read moreSource§const PHANTOM_COVARIANT: PhantomData<fn() -> Self> = PhantomData
const PHANTOM_COVARIANT: PhantomData<fn() -> Self> = PhantomData
Available on crate feature
phantom only.Source§const PHANTOM_CONTRA: PhantomData<fn(Self)> = PhantomData
const PHANTOM_CONTRA: PhantomData<fn(Self)> = PhantomData
Available on crate feature
phantom only.Source§const PHANTOM_INVARIANT: PhantomData<fn(Self) -> Self> = PhantomData
const PHANTOM_INVARIANT: PhantomData<fn(Self) -> Self> = PhantomData
Available on crate feature
phantom only.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
Mutably borrows from an owned value. Read more
Source§impl<T> CallExt for Twhere
T: ?Sized,
impl<T> CallExt for Twhere
T: ?Sized,
Source§fn ref_call<P>(&self, params: P) -> Self::Returnswhere
Self: CallRef<P>,
fn ref_call<P>(&self, params: P) -> Self::Returnswhere
Self: CallRef<P>,
Available on crate feature
callable only.For calling
CallRef::ref_call_,
with the ability to specify the types of the arguments.. Read moreSource§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Available on crate feature
self_ops only.Emulates the pipeline operator, allowing method syntax in more places. Read more
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
Available on crate feature
self_ops only.The same as
piped except that the function takes &Self
Useful for functions that take &Self instead of Self. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
Available on crate feature
self_ops only.The same as
piped, except that the function takes &mut Self.
Useful for functions that take &mut Self instead of Self.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Available on crate feature
self_ops only.Mutates self using a closure taking self by mutable reference,
passing it along the method chain. Read more
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Available on crate feature
self_ops only.Observes the value of self, passing it along unmodified.
Useful in long method chains. Read more
Source§fn as_ref_<T: ?Sized>(&self) -> &Twhere
Self: AsRef<T>,
fn as_ref_<T: ?Sized>(&self) -> &Twhere
Self: AsRef<T>,
Available on crate feature
self_ops only.Performs a reference to reference conversion with
AsRef,
using the turbofish .as_ref_::<_>() syntax. Read moreSource§impl<T> TypeIdentity for Twhere
T: ?Sized,
impl<T> TypeIdentity for Twhere
T: ?Sized,
Source§fn into_type(self) -> Self::Type
fn into_type(self) -> Self::Type
Available on crate feature
type_identity only.Converts a value back to the original type.
Source§fn as_type(&self) -> &Self::Type
fn as_type(&self) -> &Self::Type
Available on crate feature
type_identity only.Converts a reference back to the original type.
Source§fn as_type_mut(&mut self) -> &mut Self::Type
fn as_type_mut(&mut self) -> &mut Self::Type
Available on crate feature
type_identity only.Converts a mutable reference back to the original type.
Source§fn into_type_box(self: Box<Self>) -> Box<Self::Type>
fn into_type_box(self: Box<Self>) -> Box<Self::Type>
Available on crate features
type_identity and alloc only.Converts a box back to the original type.
Source§fn into_type_arc(self: Arc<Self>) -> Arc<Self::Type>
fn into_type_arc(self: Arc<Self>) -> Arc<Self::Type>
Available on crate features
type_identity and alloc only.Converts an Arc back to the original type. Read more
Source§fn into_type_rc(self: Rc<Self>) -> Rc<Self::Type>
fn into_type_rc(self: Rc<Self>) -> Rc<Self::Type>
Available on crate features
type_identity and alloc only.Converts an Rc back to the original type. Read more
Source§fn from_type(this: Self::Type) -> Self
fn from_type(this: Self::Type) -> Self
Available on crate feature
type_identity only.Converts a value back to the original type.
Source§fn from_type_ref(this: &Self::Type) -> &Self
fn from_type_ref(this: &Self::Type) -> &Self
Available on crate feature
type_identity only.Converts a reference back to the original type.
Source§fn from_type_mut(this: &mut Self::Type) -> &mut Self
fn from_type_mut(this: &mut Self::Type) -> &mut Self
Available on crate feature
type_identity only.Converts a mutable reference back to the original type.
Source§fn from_type_box(this: Box<Self::Type>) -> Box<Self>
fn from_type_box(this: Box<Self::Type>) -> Box<Self>
Available on crate features
type_identity and alloc only.Converts a box back to the original type.