pub enum OptionNull<T> {
Some(T),
Null,
None,
}
Variants§
Implementations§
Source§impl<T> OptionNull<T>
impl<T> OptionNull<T>
Sourcepub const fn is_some(&self) -> bool
pub const fn is_some(&self) -> bool
Returns true
if the OptionNull is a Some
value.
§Examples
use from::OptionNull;
let x: OptionNull<u32> = OptionNull::Some(2);
assert_eq!(x.is_some(), true);
let x: OptionNull<u32> = OptionNull::Null;
assert_eq!(x.is_some(), false);
let x: OptionNull<u32> = OptionNull::None;
assert_eq!(x.is_some(), false);
Sourcepub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool
pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool
Returns true
if the OptionNull is a [Null
] and the value inside of it matches a predicate.
§Examples
use from::OptionNull;
let x: OptionNull<u32> = OptionNull::Some(2);
assert_eq!(x.is_some_and(|x| x > 1), true);
let x: OptionNull<u32> = OptionNull::Some(0);
assert_eq!(x.is_some_and(|x| x > 1), false);
let x: OptionNull<u32> = OptionNull::Null;
assert_eq!(x.is_some_and(|x| x > 1), false);
Sourcepub const fn is_null(&self) -> bool
pub const fn is_null(&self) -> bool
Returns true
if the OptionNull is a [Null
] value.
§Examples
use from::OptionNull;
let x: OptionNull<u32> = OptionNull::Some(2);
assert_eq!(x.is_null(), false);
let x: OptionNull<u32> = OptionNull::None;
assert_eq!(x.is_null(), false);
let x: OptionNull<u32> = OptionNull::Null;
assert_eq!(x.is_null(), true);
Sourcepub const fn is_none(&self) -> bool
pub const fn is_none(&self) -> bool
Returns true
if the OptionNull is a [Null
] value.
§Examples
use from::OptionNull;
let x: OptionNull<u32> = OptionNull::Some(2);
assert_eq!(x.is_none(), false);
let x: OptionNull<u32> = OptionNull::Null;
assert_eq!(x.is_none(), false);
let x: OptionNull<u32> = OptionNull::None;
assert_eq!(x.is_none(), true);
pub const fn as_ref(&self) -> OptionNull<&T>
pub fn as_mut(&mut self) -> OptionNull<&mut T>
pub fn as_pin_ref(self: Pin<&Self>) -> OptionNull<Pin<&T>>
pub fn as_pin_mut(self: Pin<&mut Self>) -> OptionNull<Pin<&mut T>>
pub fn expect(self, msg: &str) -> T
pub fn unwrap(self) -> T
pub fn unwrap_or(self, default: T) -> T
pub fn unwrap_or_else<F>(self, f: F) -> Twhere
F: FnOnce() -> T,
pub fn unwrap_or_default(self) -> Twhere
T: Default,
pub unsafe fn unwrap_unchecked(self) -> T
pub fn map<U, F>(self, f: F) -> OptionNull<U>where
F: FnOnce(T) -> U,
pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self
pub fn map_or<U, F>(self, default: U, f: F) -> Uwhere
F: FnOnce(T) -> U,
pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U
pub fn ok_or<E>(self, err: E) -> Result<T, E>
pub fn ok_or_else<E, F>(self, err: F) -> Result<T, E>where
F: FnOnce() -> E,
pub fn as_deref(&self) -> OptionNull<&T::Target>where
T: Deref,
pub fn as_deref_mut(&mut self) -> OptionNull<&mut T::Target>where
T: DerefMut,
pub fn and<U>(self, optb: OptionNull<U>) -> OptionNull<U>
pub fn and_then<U, F>(self, f: F) -> OptionNull<U>where
F: FnOnce(T) -> OptionNull<U>,
pub fn filter<P>(self, predicate: P) -> Self
pub fn or(self, optb: OptionNull<T>) -> OptionNull<T>
pub fn or_else<F>(self, f: F) -> OptionNull<T>where
F: FnOnce() -> OptionNull<T>,
pub fn insert(&mut self, value: T) -> &mut T
pub fn get_or_insert(&mut self, value: T) -> &mut T
pub fn get_or_insert_with<F>(&mut self, f: F) -> &mut Twhere
F: FnOnce() -> T,
pub fn replace(&mut self, value: T) -> OptionNull<T>
pub fn zip<U>(self, other: OptionNull<U>) -> OptionNull<(T, U)>
Source§impl<T, U> OptionNull<(T, U)>
impl<T, U> OptionNull<(T, U)>
pub fn unzip(self) -> (OptionNull<T>, OptionNull<U>)
Source§impl<T> OptionNull<&T>
impl<T> OptionNull<&T>
pub const fn copied(self) -> OptionNull<T>where
T: Copy,
pub fn cloned(self) -> OptionNull<T>where
T: Clone,
Source§impl<T> OptionNull<&mut T>
impl<T> OptionNull<&mut T>
pub fn copied(self) -> OptionNull<T>where
T: Copy,
pub fn cloned(self) -> OptionNull<T>where
T: Clone,
Source§impl<T, E> OptionNull<Result<T, E>>
impl<T, E> OptionNull<Result<T, E>>
pub fn transpose(self) -> Result<OptionNull<T>, E>
Source§impl<T> OptionNull<OptionNull<T>>
impl<T> OptionNull<OptionNull<T>>
pub fn flatten(self) -> OptionNull<T>
Trait Implementations§
Source§impl<T> Clone for OptionNull<T>where
T: Clone,
impl<T> Clone for OptionNull<T>where
T: Clone,
Source§impl<T: Debug> Debug for OptionNull<T>
impl<T: Debug> Debug for OptionNull<T>
Source§impl<T> Default for OptionNull<T>
impl<T> Default for OptionNull<T>
Source§fn default() -> OptionNull<T>
fn default() -> OptionNull<T>
Returns the “default value” for a type. Read more
Source§impl<'a, T> From<&'a OptionNull<T>> for OptionNull<&'a T>
impl<'a, T> From<&'a OptionNull<T>> for OptionNull<&'a T>
Source§fn from(o: &'a OptionNull<T>) -> OptionNull<&'a T>
fn from(o: &'a OptionNull<T>) -> OptionNull<&'a T>
Converts to this type from the input type.
Source§impl<'a, T> From<&'a mut OptionNull<T>> for OptionNull<&'a mut T>
impl<'a, T> From<&'a mut OptionNull<T>> for OptionNull<&'a mut T>
Source§fn from(o: &'a mut OptionNull<T>) -> OptionNull<&'a mut T>
fn from(o: &'a mut OptionNull<T>) -> OptionNull<&'a mut T>
Converts to this type from the input type.
Source§impl<T> From<T> for OptionNull<T>
impl<T> From<T> for OptionNull<T>
Source§fn from(val: T) -> OptionNull<T>
fn from(val: T) -> OptionNull<T>
Converts to this type from the input type.
Source§impl<T: PartialEq> PartialEq for OptionNull<T>
impl<T: PartialEq> PartialEq for OptionNull<T>
impl<T> StructuralPartialEq for OptionNull<T>
Auto Trait Implementations§
impl<T> Freeze for OptionNull<T>where
T: Freeze,
impl<T> RefUnwindSafe for OptionNull<T>where
T: RefUnwindSafe,
impl<T> Send for OptionNull<T>where
T: Send,
impl<T> Sync for OptionNull<T>where
T: Sync,
impl<T> Unpin for OptionNull<T>where
T: Unpin,
impl<T> UnwindSafe for OptionNull<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