Access

Trait Access 

Source
pub trait Access<T>: InferPresence<T> {
    type RemainderFrom<Source: Access<T>>: Access<T>;

    const IS_ABSENT: bool;

    // Required methods
    fn get(&self) -> Option<&T>;
    fn get_mut(&mut self) -> Option<&mut T>;
    fn into_option(self) -> Option<T>;
}
Expand description

Uniform field access for Present, Optional, or Absent.

Required Associated Constants§

Source

const IS_ABSENT: bool

Compile-time constant indicating if this field is absent.

Required Associated Types§

Source

type RemainderFrom<Source: Access<T>>: Access<T>

Remainder type when extracting Self from Source.

Required Methods§

Source

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

Get field reference if present.

Source

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

Get mutable field reference if present.

Source

fn into_option(self) -> Option<T>

Consume and convert to Option.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> Access<T> for Option<T>

Source§

const IS_ABSENT: bool = false

Source§

type RemainderFrom<Source: Access<T>> = PhantomData<T>

Source§

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

Source§

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

Source§

fn into_option(self) -> Option<T>

Source§

impl<T> Access<T> for PhantomData<T>

Source§

const IS_ABSENT: bool = true

Source§

type RemainderFrom<Source: Access<T>> = Source

Source§

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

Source§

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

Source§

fn into_option(self) -> Option<T>

Implementors§

Source§

impl<T: Sized> Access<T> for T

Source§

const IS_ABSENT: bool = false

Source§

type RemainderFrom<Source: Access<T>> = PhantomData<T>