Trait Nullable

Source
pub trait Nullable {
    const NULL: Self;

    // Required method
    fn is_null(&self) -> bool;
}
Expand description

Any type that can be some form of null.

Required Associated Constants§

Source

const NULL: Self

Whatever value of Self means null.

For *const _, this is std::ptr::null().

For *mut _, this is std::ptr::null_mut().

See also NoneIsNull

Required Methods§

Source

fn is_null(&self) -> bool

Just a null check without relying on PartialEq (i.e., ptr == null()).

For *const _ and *mut _, this uses the inherent method of the same name.

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> Nullable for *const T

Source§

const NULL: Self

Source§

fn is_null(&self) -> bool

Source§

impl<T> Nullable for *mut T

Source§

const NULL: Self

Source§

fn is_null(&self) -> bool

Source§

impl<T: NoneIsNull> Nullable for Option<T>

Source§

const NULL: Self = None

Source§

fn is_null(&self) -> bool

Implementors§