1 2 3 4 5 6 7 8 9 10 11 12 13 14
pub trait IfThen { fn if_then<FCompare, FExecute>(self, _if: FCompare, then: FExecute) where Self: Sized, FCompare: Fn(&Self) -> bool, FExecute: FnOnce(Self), { if _if(&self) { then(self); } } } impl<T> IfThen for T {}