Access

Trait Access 

Source
pub trait Access<T> {
    const IS_ABSENT: bool;

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

Trait for uniformly accessing fields that may be Present, Optional, or Absent.

Required Associated Constants§

Source

const IS_ABSENT: bool

Compile-time constant indicating if this field is absent.

Required Methods§

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.

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§

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

Source§

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

Source§

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

Source§

const IS_ABSENT: bool = true

Source§

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

Source§

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

Implementors§

Source§

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

Source§

const IS_ABSENT: bool = false