pub enum Erm<T> {
Yes(T),
No,
Maybe(T),
MaybeNot,
DontKnow,
}Expand description
You can use this like an Option with the first two variants, but you can do…more.
Variants§
Yes(T)
This is Option::Some. It works.
No
This is Option::None. It does not work.
Maybe(T)
Outputs of randomised procedures, for example, can be represented with this variant. It means you’re confident enough in the outcome that you’d like to go ahead with it, while making sure you remember that stuff could go wrong.
MaybeNot
This variant is for when it’s probably a good idea to treat the outcome as a failure, but if you’re really optimistic, you can still try it.
DontKnow
No promises. You really should retry or something.
Implementations§
Source§impl<T> Erm<T>
impl<T> Erm<T>
Sourcepub fn might_not_be(&self) -> bool
pub fn might_not_be(&self) -> bool
Pessimistic.
pub fn known(&self) -> bool
pub fn unknown(&self) -> bool
pub const fn as_ref(&self) -> Erm<&T>
pub const fn as_mut(&mut self) -> Erm<&mut T>
pub fn expect(self, msg: &str) -> T
pub fn expect_sure(self, msg: &str) -> T
pub fn unwrap(self) -> T
pub fn unwrap_sure(self) -> T
pub fn unwrap_or(self, default: T) -> T
pub fn unwrap_sure_or(self, default: T) -> T
pub fn unwrap_or_else(self, f: impl FnOnce() -> T) -> T
pub fn unwrap_sure_or_else(self, f: impl FnOnce() -> T) -> T
pub fn unwrap_or_default(self) -> Twhere
T: Default,
pub fn unwrap_sure_or_default(self) -> Twhere
T: Default,
pub unsafe fn unwrap_unchecked(self) -> T
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Erm<U>
pub fn inspect(self, f: impl FnOnce(&T)) -> Erm<T>
pub fn map_or<U>(self, default: U, f: impl FnOnce(T) -> U) -> U
pub fn map_or_else<U>( self, default: impl FnOnce() -> U, f: impl FnOnce(T) -> U, ) -> U
pub fn map_or_default<U, F>(self, f: F) -> U
pub fn ok_or(self, err: T) -> Result<T, T>
pub fn sure_or(self, err: T) -> Result<T, T>
pub fn ok_or_else(self, err: impl FnOnce() -> T) -> Result<T, T>
pub fn sure_or_else(self, err: impl FnOnce() -> T) -> Result<T, T>
pub fn as_deref(&self) -> Erm<&T::Target>where
T: Deref,
pub fn as_deref_mut(&mut self) -> Erm<&mut T::Target>where
T: DerefMut,
pub const fn take(&mut self) -> Erm<T>
pub fn ensure(self) -> Erm<T>
pub fn and<U>(self, other: Erm<U>) -> Erm<U>
pub fn and_sure<U>(self, other: Erm<U>) -> Erm<U>
pub fn and_then<U, F>(self, f: F) -> Erm<U>
pub fn and_then_sure<U, F>(self, f: F) -> Erm<U>
pub fn filter<P>(self, predicate: P) -> Erm<T>
pub fn or(self, optb: Erm<T>) -> Erm<T>
pub fn or_sure(self, optb: Erm<T>) -> Erm<T>
pub fn or_else(self, f: impl FnOnce() -> Erm<T>) -> Erm<T>
pub fn or_else_sure(self, f: impl FnOnce() -> Erm<T>) -> Erm<T>
pub fn xor(self, other: Erm<T>) -> Erm<T>
pub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T> ⓘ
pub fn insert(&mut self, value: T) -> &mut T
pub fn insert_maybe(&mut self, value: T) -> &mut T
pub fn get_or_insert(&mut self, value: T) -> &mut T
pub fn get_or_insert_maybe(&mut self, value: T) -> &mut T
pub fn get_or_insert_with<F>(&mut self, f: F) -> &mut Twhere
F: FnOnce() -> T,
pub fn get_or_insert_with_maybe<F>(&mut self, f: F) -> &mut Twhere
F: FnOnce() -> T,
pub fn get_or_insert_default(&mut self) -> &mut Twhere
T: Default,
pub fn take_if<P>(&mut self, predicate: P) -> Erm<T>
pub const fn replace(&mut self, value: T) -> Erm<T>
pub fn zip<U>(self, other: Erm<U>) -> Erm<(T, U)>
pub fn zip_or_default<U>(self, other: Erm<U>) -> Erm<(T, U)>
pub fn zip_with<U, F>(self, other: Erm<U>, f: F) -> Erm<T>where
F: FnOnce(T, U) -> T,
Trait Implementations§
Source§impl<'a, T> IntoIterator for &'a Erm<T>
impl<'a, T> IntoIterator for &'a Erm<T>
Source§impl<'a, T> IntoIterator for &'a mut Erm<T>
impl<'a, T> IntoIterator for &'a mut Erm<T>
Source§impl<T> IntoIterator for Erm<T>
impl<T> IntoIterator for Erm<T>
impl<T: Copy> Copy for Erm<T>
impl<T: Eq> Eq for Erm<T>
impl<T> StructuralPartialEq for Erm<T>
Auto Trait Implementations§
impl<T> Freeze for Erm<T>where
T: Freeze,
impl<T> RefUnwindSafe for Erm<T>where
T: RefUnwindSafe,
impl<T> Send for Erm<T>where
T: Send,
impl<T> Sync for Erm<T>where
T: Sync,
impl<T> Unpin for Erm<T>where
T: Unpin,
impl<T> UnwindSafe for Erm<T>where
T: UnwindSafe,
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