Trait ApplyAssign

Source
pub trait ApplyAssign<T> {
    // Required method
    fn app_ass<F>(&mut self, f: F)
       where F: FnOnce(T) -> T;
}

Required Methods§

Source

fn app_ass<F>(&mut self, f: F)
where F: FnOnce(T) -> T,

Applies a function to a variable and sets the variable to the resulting value

§Examples
use crate::dbulfin_lib::ApplyAssign;

let mut x = (1, 2);
x.app_ass(|(x, y)| (y, x));
assert_eq!(x, (2, 1))

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.

Implementors§

Source§

impl<T> ApplyAssign<T> for T
where T: Clone,