pub enum Probably<T> {
Nothing,
Something(T),
}Variants§
Implementations§
Source§impl<T> Probably<T>
impl<T> Probably<T>
Sourcepub const fn is_nothing(&self) -> bool
pub const fn is_nothing(&self) -> bool
Returns true if self is of variant Nothing.
Sourcepub const fn is_something(&self) -> bool
pub const fn is_something(&self) -> bool
Returns true if self is of variant Something.
Sourcepub fn as_something(&self) -> Option<&T>
pub fn as_something(&self) -> Option<&T>
Returns Some if self is a reference of variant Something, and None otherwise.
Sourcepub fn as_mut_something(&mut self) -> Option<&mut T>
pub fn as_mut_something(&mut self) -> Option<&mut T>
Returns Some if self is a mutable reference of variant Something, and None otherwise.
Sourcepub fn expect_something(self) -> Twhere
Self: Debug,
pub fn expect_something(self) -> Twhere
Self: Debug,
Source§impl<T> Probably<Probably<T>>
impl<T> Probably<Probably<T>>
Sourcepub fn flatten(self) -> Probably<T>
pub fn flatten(self) -> Probably<T>
Converts from Probably<Probably<T>> to Probably<T>.
§Examples
Basic usage:
let x: Probably<Probably<u32>> = Something(Something(6));
assert_eq!(Something(6), x.flatten());
let x: Probably<Probably<u32>> = Something(Nothing);
assert_eq!(Nothing, x.flatten());
let x: Probably<Probably<u32>> = Nothing;
assert_eq!(Nothing, x.flatten());Flattening only removes one level of nesting at a time:
let x: Probably<Probably<Probably<u32>>> = Something(Something(Something(6)));
assert_eq!(Something(Something(6)), x.flatten());
assert_eq!(Something(6), x.flatten().flatten());Trait Implementations§
Source§impl<T> FromResidual for Probably<T>
impl<T> FromResidual for Probably<T>
Source§fn from_residual(residual: Probably<Infallible>) -> Self
fn from_residual(residual: Probably<Infallible>) -> Self
🔬This is a nightly-only experimental API. (
try_trait_v2)Constructs the type from a compatible
Residual type. Read moreSource§impl<T: Ord> Ord for Probably<T>
impl<T: Ord> Ord for Probably<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Probably<T>
impl<T: PartialOrd> PartialOrd for Probably<T>
Source§impl<T> Termination for Probably<T>
impl<T> Termination for Probably<T>
Source§impl<T> Try for Probably<T>
impl<T> Try for Probably<T>
Source§type Output = T
type Output = T
🔬This is a nightly-only experimental API. (
try_trait_v2)The type of the value produced by
? when not short-circuiting.Source§type Residual = Probably<Infallible>
type Residual = Probably<Infallible>
🔬This is a nightly-only experimental API. (
try_trait_v2)The type of the value passed to
FromResidual::from_residual
as part of ? when short-circuiting. Read moreSource§fn from_output(output: Self::Output) -> Self
fn from_output(output: Self::Output) -> Self
🔬This is a nightly-only experimental API. (
try_trait_v2)Constructs the type from its
Output type. Read moreSource§fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
🔬This is a nightly-only experimental API. (
try_trait_v2)Used in
? to decide whether the operator should produce a value
(because this returned ControlFlow::Continue)
or propagate a value back to the caller
(because this returned ControlFlow::Break). Read moreimpl<T: Copy> Copy for Probably<T>
impl<T: Eq> Eq for Probably<T>
impl<T> StructuralPartialEq for Probably<T>
Auto Trait Implementations§
impl<T> Freeze for Probably<T>where
T: Freeze,
impl<T> RefUnwindSafe for Probably<T>where
T: RefUnwindSafe,
impl<T> Send for Probably<T>where
T: Send,
impl<T> Sync for Probably<T>where
T: Sync,
impl<T> Unpin for Probably<T>where
T: Unpin,
impl<T> UnwindSafe for Probably<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