Optional

Trait Optional 

Source
pub trait Optional<T>: Default + From<T> {
    // Required methods
    fn to_option_ref(&self) -> Option<&T>;
    fn to_option_mut(&mut self) -> Option<&mut T>;
    fn into_option(self) -> Option<T>;
}
Expand description

A trait that represents an optional value.

This is a complement to std::option::Option that allows implementations to choose how to represent Some and None.

Required Methods§

Source

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

Returns an Option<&T> that is equivalent to this Optional.

Source

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

Returns an Option<&mut T> that is equivalent to this Optional.

Source

fn into_option(self) -> Option<T>

Converts this Optional to the equivalent 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> Optional<T> for Option<T>

Implementors§

Source§

impl Optional<bool> for OptionalBool

Source§

impl<T, B> Optional<T> for Optioned<T, B>
where T: Eq, B: BuildNone<T>,