Optional

Struct Optional 

Source
pub struct Optional;
Expand description

Marker indicating a field may or may not be present (Option).

Trait Implementations§

Source§

impl Presence for Optional

Source§

type OptionOrSelf = Optional

The presence state when combined with an Option.
Source§

type Or<Other: Presence> = <Other as Presence>::OptionOrSelf

Result of merging this presence with another.
Source§

type RemainderFrom<Source: Presence> = Absent

What remains from Source when extracting Self. Present/Optional → Absent; Absent → Source.
Source§

type Output<T> = Option<T>

The container type for values with this presence (T, Option<T>, or PhantomData<T>).
Source§

fn or<T, Other: Presence>( self_: <Self as Presence>::Output<T>, other: Other::Output<T>, ) -> <<Self as Presence>::Or<Other> as Presence>::Output<T>

Merge two values, preferring the first if present.
Source§

fn option_or_self<T>( option: Option<T>, self_: <Self as Presence>::Output<T>, ) -> <<Self as Presence>::OptionOrSelf as Presence>::Output<T>

Convert an Option into the appropriate presence state.
Source§

impl Split<Absent> for Optional

Source§

fn split<T>(value: Option<T>) -> (PhantomData<T>, Option<T>)

Split a value into selected and remainder parts.
Source§

impl Split<Optional> for Absent

Source§

fn split<T>(_value: PhantomData<T>) -> (Option<T>, PhantomData<T>)

Split a value into selected and remainder parts.
Source§

impl Split<Optional> for Optional

Source§

fn split<T>(value: Option<T>) -> (Option<T>, PhantomData<T>)

Split a value into selected and remainder parts.
Source§

impl Split<Optional> for Present

Source§

fn split<T>(value: T) -> (Option<T>, PhantomData<T>)

Split a value into selected and remainder parts.
Source§

impl TrySplit<Present> for Optional

Source§

fn try_split<T>(value: Option<T>) -> Result<(T, PhantomData<T>), Option<T>>

Try to split a value into selected and remainder parts. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Access<T> for T

Source§

const IS_ABSENT: bool = false

Compile-time constant indicating if this field is absent.
Source§

fn get(&self) -> Option<&T>

Get a reference to the field value if present.
Source§

fn get_mut(&mut self) -> Option<&mut T>

Get a mutable reference to the field value if present.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InferPresence<T> for T

Source§

type Presence = Present

The presence state corresponding to this value type.
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, 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.
Source§

impl<From, To> TrySplit<To> for From
where From: Presence + Split<To>, To: Presence,

Source§

fn try_split<T>( value: <From as Presence>::Output<T>, ) -> Result<(<To as Presence>::Output<T>, <<To as Presence>::RemainderFrom<From> as Presence>::Output<T>), <From as Presence>::Output<T>>

Try to split a value into selected and remainder parts. Read more