Skip to main content

OptionExt

Trait OptionExt 

Source
pub trait OptionExt<T> {
Show 17 methods // Required methods fn with<R>(&self, f: impl FnOnce(&T) -> R) -> Option<R>; fn with_mut<R>(&mut self, f: impl FnOnce(&mut T) -> R) -> Option<R>; fn with_if<R, U>( &self, o: &Option<U>, f: impl FnOnce(&T, &U) -> R, ) -> Option<R>; fn with_mut_if<R, U>( &mut self, o: &Option<U>, f: impl FnOnce(&mut T, &U) -> R, ) -> Option<R>; fn with_mut_if_saturating<R>( &mut self, o: Option<T>, f: impl FnOnce(&mut T, &T) -> R, ) -> Option<R>; fn add_to<V>(&mut self, v: V) where T: AddAssign<V>; fn sub_to<V>(&mut self, v: V) where T: SubAssign<V>; fn mul_to<V>(&mut self, v: V) where T: MulAssign<V>; fn div_to<V>(&mut self, v: V) where T: DivAssign<V>; fn add_to_lossy<V>(&mut self, v: Option<V>) where T: AddAssign<V>; fn sub_to_lossy<V>(&mut self, v: Option<V>) where T: SubAssign<V>; fn mul_to_lossy<V>(&mut self, v: Option<V>) where T: MulAssign<V>; fn div_to_lossy<V>(&mut self, v: Option<V>) where T: DivAssign<V>; fn add_to_if<V>(&mut self, v: Option<V>) where T: AddAssign<V>; fn sub_to_if<V>(&mut self, v: Option<V>) where T: SubAssign<V>; fn mul_to_if<V>(&mut self, v: Option<V>) where T: MulAssign<V>; fn div_to_if<V>(&mut self, v: Option<V>) where T: DivAssign<V>;
}

Required Methods§

Source

fn with<R>(&self, f: impl FnOnce(&T) -> R) -> Option<R>

Source

fn with_mut<R>(&mut self, f: impl FnOnce(&mut T) -> R) -> Option<R>

Source

fn with_if<R, U>(&self, o: &Option<U>, f: impl FnOnce(&T, &U) -> R) -> Option<R>

Source

fn with_mut_if<R, U>( &mut self, o: &Option<U>, f: impl FnOnce(&mut T, &U) -> R, ) -> Option<R>

Source

fn with_mut_if_saturating<R>( &mut self, o: Option<T>, f: impl FnOnce(&mut T, &T) -> R, ) -> Option<R>

Source

fn add_to<V>(&mut self, v: V)
where T: AddAssign<V>,

Source

fn sub_to<V>(&mut self, v: V)
where T: SubAssign<V>,

Source

fn mul_to<V>(&mut self, v: V)
where T: MulAssign<V>,

Source

fn div_to<V>(&mut self, v: V)
where T: DivAssign<V>,

Source

fn add_to_lossy<V>(&mut self, v: Option<V>)
where T: AddAssign<V>,

Source

fn sub_to_lossy<V>(&mut self, v: Option<V>)
where T: SubAssign<V>,

Source

fn mul_to_lossy<V>(&mut self, v: Option<V>)
where T: MulAssign<V>,

Source

fn div_to_lossy<V>(&mut self, v: Option<V>)
where T: DivAssign<V>,

Source

fn add_to_if<V>(&mut self, v: Option<V>)
where T: AddAssign<V>,

Source

fn sub_to_if<V>(&mut self, v: Option<V>)
where T: SubAssign<V>,

Source

fn mul_to_if<V>(&mut self, v: Option<V>)
where T: MulAssign<V>,

Source

fn div_to_if<V>(&mut self, v: Option<V>)
where T: DivAssign<V>,

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> OptionExt<T> for Option<T>

Source§

fn with<R>(&self, f: impl FnOnce(&T) -> R) -> Option<R>

Source§

fn with_mut<R>(&mut self, f: impl FnOnce(&mut T) -> R) -> Option<R>

Source§

fn with_if<R, U>(&self, o: &Option<U>, f: impl FnOnce(&T, &U) -> R) -> Option<R>

Source§

fn with_mut_if<R, U>( &mut self, o: &Option<U>, f: impl FnOnce(&mut T, &U) -> R, ) -> Option<R>

Source§

fn with_mut_if_saturating<R>( &mut self, o: Option<T>, f: impl FnOnce(&mut T, &T) -> R, ) -> Option<R>

Source§

fn add_to<V>(&mut self, v: V)
where T: AddAssign<V>,

Source§

fn sub_to<V>(&mut self, v: V)
where T: SubAssign<V>,

Source§

fn mul_to<V>(&mut self, v: V)
where T: MulAssign<V>,

Source§

fn div_to<V>(&mut self, v: V)
where T: DivAssign<V>,

Source§

fn add_to_lossy<V>(&mut self, v: Option<V>)
where T: AddAssign<V>,

Source§

fn sub_to_lossy<V>(&mut self, v: Option<V>)
where T: SubAssign<V>,

Source§

fn mul_to_lossy<V>(&mut self, v: Option<V>)
where T: MulAssign<V>,

Source§

fn div_to_lossy<V>(&mut self, v: Option<V>)
where T: DivAssign<V>,

Source§

fn add_to_if<V>(&mut self, v: Option<V>)
where T: AddAssign<V>,

Source§

fn sub_to_if<V>(&mut self, v: Option<V>)
where T: SubAssign<V>,

Source§

fn mul_to_if<V>(&mut self, v: Option<V>)
where T: MulAssign<V>,

Source§

fn div_to_if<V>(&mut self, v: Option<V>)
where T: DivAssign<V>,

Implementors§