IOption

Struct IOption 

Source
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>

Source

pub const fn new(value: T) -> Self

Source

pub const fn none() -> Self

Source

pub fn is_none(&self) -> bool

Source

pub fn is_some(&self) -> bool

Source

pub fn into_inner(self) -> T

Source

pub fn as_ref(&self) -> Option<&T>

Source

pub fn as_mut(&mut self) -> Option<&mut T>

Source

pub fn map<U, F>(self, f: F) -> IOption<U>
where U: Nullable, F: FnOnce(T) -> U,

Source

pub fn map_or<U, F>(self, default: U, f: F) -> U
where U: Nullable, F: FnOnce(T) -> U,

Source

pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U
where U: Nullable, D: FnOnce() -> U, F: FnOnce(T) -> U,

Source

pub fn ok_or<E>(self, err: E) -> Result<T, E>

Source

pub fn ok_or_else<E, F>(self, err: F) -> Result<T, E>
where F: FnOnce() -> E,

Source

pub fn and<U>(self, other: IOption<U>) -> IOption<U>
where U: Nullable,

Source

pub fn and_then<U, F>(self, f: F) -> IOption<U>
where U: Nullable, F: FnOnce(T) -> IOption<U>,

Source

pub fn or(self, other: IOption<T>) -> IOption<T>
where T: Nullable,

Source

pub fn or_else<F>(self, f: F) -> IOption<T>
where T: Nullable, F: FnOnce() -> IOption<T>,

Source

pub fn unwrap(self) -> T

Source

pub fn unwrap_or(self, default: T) -> T

Source

pub fn unwrap_or_else<F>(self, f: F) -> T
where F: FnOnce() -> T,

Source

pub fn expect(self, msg: &str) -> T

Source

pub fn iter(&self) -> IntoIter<&T>

Source

pub fn iter_mut(&mut self) -> IntoIter<&mut T>

Source

pub fn filter<P>(self, predicate: P) -> IOption<T>
where P: FnOnce(&T) -> bool,

Source

pub fn take(&mut self) -> IOption<T>

Source

pub fn replace(&mut self, value: T) -> IOption<T>

Source

pub fn get_or_insert(&mut self, value: T) -> &mut T

Source

pub fn get_or_insert_with<F>(&mut self, f: F) -> &mut T
where F: FnOnce() -> T,

Source

pub fn get_or_insert_default(&mut self) -> &mut T
where T: Default,

Trait Implementations§

Source§

impl<T: Clone + Nullable> Clone for IOption<T>

Source§

fn clone(&self) -> IOption<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Nullable> Debug for IOption<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Nullable> Default for IOption<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Nullable> From<IOption<T>> for Option<T>

Source§

fn from(ioption: IOption<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Nullable> From<Option<T>> for IOption<T>

Source§

fn from(option: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Nullable> From<T> for IOption<T>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash + Nullable> Hash for IOption<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Ord + Nullable> Ord for IOption<T>

Source§

fn cmp(&self, other: &IOption<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq + Nullable> PartialEq for IOption<T>

Source§

fn eq(&self, other: &IOption<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd + Nullable> PartialOrd for IOption<T>

Source§

fn partial_cmp(&self, other: &IOption<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Copy + Nullable> Copy for IOption<T>

Source§

impl<T: Eq + Nullable> Eq for IOption<T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.