Enum OptionNull

Source
pub enum OptionNull<T> {
    Some(T),
    Null,
    None,
}

Variants§

§

Some(T)

§

Null

§

None

Implementations§

Source§

impl<T> OptionNull<T>

Source

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

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

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

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

pub const fn as_ref(&self) -> OptionNull<&T>

Source

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

Source

pub fn as_pin_ref(self: Pin<&Self>) -> OptionNull<Pin<&T>>

Source

pub fn as_pin_mut(self: Pin<&mut Self>) -> OptionNull<Pin<&mut T>>

Source

pub fn expect(self, msg: &str) -> 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 unwrap_or_default(self) -> T
where T: Default,

Source

pub unsafe fn unwrap_unchecked(self) -> T

Source

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

Source

pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self

Source

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

Source

pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U
where 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 as_deref(&self) -> OptionNull<&T::Target>
where T: Deref,

Source

pub fn as_deref_mut(&mut self) -> OptionNull<&mut T::Target>
where T: DerefMut,

Source

pub fn and<U>(self, optb: OptionNull<U>) -> OptionNull<U>

Source

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

Source

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

Source

pub fn or(self, optb: OptionNull<T>) -> OptionNull<T>

Source

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

Source

pub fn insert(&mut self, value: T) -> &mut 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 replace(&mut self, value: T) -> OptionNull<T>

Source

pub fn zip<U>(self, other: OptionNull<U>) -> OptionNull<(T, U)>

Source§

impl<T, U> OptionNull<(T, U)>

Source

pub fn unzip(self) -> (OptionNull<T>, OptionNull<U>)

Source§

impl<T> OptionNull<&T>

Source

pub const fn copied(self) -> OptionNull<T>
where T: Copy,

Source

pub fn cloned(self) -> OptionNull<T>
where T: Clone,

Source§

impl<T> OptionNull<&mut T>

Source

pub fn copied(self) -> OptionNull<T>
where T: Copy,

Source

pub fn cloned(self) -> OptionNull<T>
where T: Clone,

Source§

impl<T, E> OptionNull<Result<T, E>>

Source

pub fn transpose(self) -> Result<OptionNull<T>, E>

Source§

impl<T> OptionNull<OptionNull<T>>

Source

pub fn flatten(self) -> OptionNull<T>

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for OptionNull<T>

Source§

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

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

impl<T> Default for OptionNull<T>

Source§

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>

Source§

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>

Source§

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>

Source§

fn from(val: T) -> OptionNull<T>

Converts to this type from the input type.
Source§

impl<T: PartialEq> PartialEq for OptionNull<T>

Source§

fn eq(&self, other: &OptionNull<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> 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> 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<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
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.