pub enum Never {}
Expand description
Never can never be instantiated. This can be used in places
where we want to ensure that no error is returned, such as
the ibc_packet_receive
entry point.
In contrast to Empty
, this does not have a JSON schema
and cannot be used for message and query types.
Once the ! type is stable, this is not needed anymore. See https://github.com/rust-lang/rust/issues/35121.
§Examples
When using Never
in a Result
, we can unwrap in a type-safe way:
use cosmwasm_std::Never;
pub fn safe_unwrap<T>(res: Result<T, Never>) -> T {
match res {
Ok(value) => value,
Err(err) => match err {},
}
}
let res: Result<i32, Never> = Ok(5);
assert_eq!(safe_unwrap(res), 5);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Never
impl RefUnwindSafe for Never
impl Send for Never
impl Sync for Never
impl Unpin for Never
impl UnwindSafe for Never
Blanket Implementations§
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> 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>
Converts
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>
Converts
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