pub struct IOption<T: Nullable>(/* private fields */);Expand description
The IOption type, a transparent newtype wrapper around a Nullable value that provides a similar API to Option.
See the module-level documentation for more information.
Implementations§
Source§impl<T: Nullable> IOption<T>
impl<T: Nullable> IOption<T>
pub const fn new(value: T) -> Self
pub const fn none() -> Self
pub fn is_none(&self) -> bool
pub fn is_some(&self) -> bool
pub fn into_inner(self) -> T
pub fn as_ref(&self) -> Option<&T>
pub fn as_mut(&mut self) -> Option<&mut T>
pub fn map<U, F>(self, f: F) -> IOption<U>
pub fn map_or<U, F>(self, default: U, f: F) -> 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 and<U>(self, other: IOption<U>) -> IOption<U>where
U: Nullable,
pub fn and_then<U, F>(self, f: F) -> IOption<U>
pub fn or(self, other: IOption<T>) -> IOption<T>where
T: Nullable,
pub fn or_else<F>(self, f: F) -> IOption<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 expect(self, msg: &str) -> T
pub fn iter(&self) -> IntoIter<&T>
pub fn iter_mut(&mut self) -> IntoIter<&mut T>
pub fn filter<P>(self, predicate: P) -> IOption<T>
pub fn take(&mut self) -> IOption<T>
pub fn replace(&mut self, value: T) -> IOption<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 get_or_insert_default(&mut self) -> &mut Twhere
T: Default,
Trait Implementations§
Source§impl<T: Ord + Nullable> Ord for IOption<T>
impl<T: Ord + Nullable> Ord for IOption<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 + Nullable> PartialOrd for IOption<T>
impl<T: PartialOrd + Nullable> PartialOrd for IOption<T>
impl<T: Copy + Nullable> Copy for IOption<T>
impl<T: Eq + Nullable> Eq for IOption<T>
impl<T: Nullable> StructuralPartialEq for IOption<T>
Auto Trait Implementations§
impl<T> Freeze for IOption<T>where
T: Freeze,
impl<T> RefUnwindSafe for IOption<T>where
T: RefUnwindSafe,
impl<T> Send for IOption<T>where
T: Send,
impl<T> Sync for IOption<T>where
T: Sync,
impl<T> Unpin for IOption<T>where
T: Unpin,
impl<T> UnwindSafe for IOption<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