Skip to main content

Nullable

Trait Nullable 

Source
pub trait Nullable: PartialEq + Sized {
    const NONE: Self;

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

Trait for types that can be None.

This trait is used to indicate that a type can reserve a specific value to represent None.

Required Associated Constants§

Source

const NONE: Self

Value that represents None for the type.

Provided Methods§

Source

fn is_none(&self) -> bool

Indicates whether the value is None or not.

Source

fn is_some(&self) -> bool

Indicates whether the value is a Some value of type Self or not.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Nullable for u8

Implements Nullable for the u8 type, reserving 0 as the NONE value.

Source§

const NONE: Self = 0

Source§

impl Nullable for u16

Implements Nullable for the u16 type, reserving 0 as the NONE value.

Source§

const NONE: Self = 0

Source§

impl Nullable for u32

Implements Nullable for the u32 type, reserving 0 as the NONE value.

Source§

const NONE: Self = 0

Source§

impl Nullable for u64

Implements Nullable for the u64 type, reserving 0 as the NONE value.

Source§

const NONE: Self = 0

Source§

impl Nullable for u128

Implements Nullable for the u128 type, reserving 0 as the NONE value.

Source§

const NONE: Self = 0

Implementors§