Trait freya::prelude::WritableOptionExt

pub trait WritableOptionExt<T>: Writable<Target = Option<T>>
where T: 'static,
{ // Provided methods fn get_or_insert(&mut self, default: T) -> Self::Mut<'_, T> { ... } fn get_or_insert_with( &mut self, default: impl FnOnce() -> T, ) -> Self::Mut<'_, T> { ... } fn as_mut(&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(&mut 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( &mut 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(&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 W
where T: 'static, W: Writable<Target = Option<T>>,