Trait Optional

Source
pub trait Optional: Copy {
    type Inner: Copy;

    // Required methods
    fn none() -> Self;
    fn some(v: Self::Inner) -> Self;
    fn is_none(&self) -> bool;
    fn inner(&self) -> Option<Self::Inner>;

    // Provided method
    fn is_some(&self) -> bool { ... }
}
Expand description

To represent empty trie entry. Provided implementations for integer primitive types as -1 represents None.

Required Associated Types§

Required Methods§

Source

fn none() -> Self

Source

fn some(v: Self::Inner) -> Self

Source

fn is_none(&self) -> bool

Source

fn inner(&self) -> Option<Self::Inner>

Provided Methods§

Source

fn is_some(&self) -> bool

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 Optional for u8

Source§

type Inner = u8

Source§

fn none() -> Self

Source§

fn some(v: Self::Inner) -> Self

Source§

fn is_none(&self) -> bool

Source§

fn inner(&self) -> Option<Self::Inner>

Source§

impl Optional for u16

Source§

type Inner = u16

Source§

fn none() -> Self

Source§

fn some(v: Self::Inner) -> Self

Source§

fn is_none(&self) -> bool

Source§

fn inner(&self) -> Option<Self::Inner>

Source§

impl Optional for u32

Source§

type Inner = u32

Source§

fn none() -> Self

Source§

fn some(v: Self::Inner) -> Self

Source§

fn is_none(&self) -> bool

Source§

fn inner(&self) -> Option<Self::Inner>

Source§

impl Optional for u64

Source§

type Inner = u64

Source§

fn none() -> Self

Source§

fn some(v: Self::Inner) -> Self

Source§

fn is_none(&self) -> bool

Source§

fn inner(&self) -> Option<Self::Inner>

Source§

impl Optional for u128

Source§

type Inner = u128

Source§

fn none() -> Self

Source§

fn some(v: Self::Inner) -> Self

Source§

fn is_none(&self) -> bool

Source§

fn inner(&self) -> Option<Self::Inner>

Source§

impl Optional for usize

Source§

type Inner = usize

Source§

fn none() -> Self

Source§

fn some(v: Self::Inner) -> Self

Source§

fn is_none(&self) -> bool

Source§

fn inner(&self) -> Option<Self::Inner>

Source§

impl<T: Copy> Optional for Option<T>

Source§

type Inner = T

Source§

fn none() -> Self

Source§

fn some(v: Self::Inner) -> Self

Source§

fn is_none(&self) -> bool

Source§

fn inner(&self) -> Option<Self::Inner>

Implementors§