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<T>>
` that provides some convenience methods.
Provided Methods§
sourcefn get_or_insert(&mut self, default: T) -> Self::Mut<'_, T>
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.
sourcefn get_or_insert_with(
&mut self,
default: impl FnOnce() -> T,
) -> Self::Mut<'_, T>
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.
Object Safety§
This trait is not object safe.