pub trait WritableOptionExt<T>: Writable<Option<T>>where
    T: 'static,{
    // Provided methods
    fn get_or_insert(&self, default: T) -> Self::Mut<T> { ... }
    fn get_or_insert_with(&self, default: impl FnOnce() -> T) -> Self::Mut<T> { ... }
    fn as_mut(&self) -> Option<Self::Mut<T>> { ... }
}
Expand description

An extension trait for Writable<Option> that provides some convenience methods.

Provided Methods§

fn get_or_insert(&self, default: T) -> Self::Mut<T>

Gets the value out of the Option, or inserts the given value if the Option is empty.

fn get_or_insert_with(&self, default: impl FnOnce() -> T) -> Self::Mut<T>

Gets the value out of the Option, or inserts the value returned by the given function if the Option is empty.

fn as_mut(&self) -> Option<Self::Mut<T>>

Attempts to write the inner value of the Option.

Object Safety§

This trait is not object safe.

Implementors§

§

impl<T, W> WritableOptionExt<T> for Wwhere T: 'static, W: Writable<Option<T>>,