pub trait TransformExt {
// Required methods
fn transform<Q>(self, _: impl FnOnce(Self) -> Q) -> Q
where Self: Sized;
fn transform_if(self, _: bool, _: impl FnOnce(Self) -> Self) -> Self
where Self: Sized;
fn modify<Q>(self, _: impl FnOnce(&mut Self) -> Q) -> Self
where Self: Sized;
fn modify_if<Q>(self, _: bool, _: impl FnOnce(&mut Self) -> Q) -> Self
where Self: Sized;
fn cmp_exch<'a, E>(&'a mut self, _: E, _: Self) -> bool
where &'a mut Self: PartialEq<E>;
fn cmp_replace(&mut self, _: Self) -> bool
where Self: PartialEq;
fn dbg(self) -> Self
where Self: Debug;
}Required Methods§
fn transform<Q>(self, _: impl FnOnce(Self) -> Q) -> Qwhere
Self: Sized,
Sourcefn transform_if(self, _: bool, _: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn transform_if(self, _: bool, _: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn modify<Q>(self, _: impl FnOnce(&mut Self) -> Q) -> Selfwhere
Self: Sized,
Sourcefn modify_if<Q>(self, _: bool, _: impl FnOnce(&mut Self) -> Q) -> Selfwhere
Self: Sized,
fn modify_if<Q>(self, _: bool, _: impl FnOnce(&mut Self) -> Q) -> Selfwhere
Self: Sized,
§Example
use cba::bait::TransformExt;
true.modify_if(cfg!(debug_assertions), |x| *dbg!(x));Sourcefn cmp_exch<'a, E>(&'a mut self, _: E, _: Self) -> boolwhere
&'a mut Self: PartialEq<E>,
fn cmp_exch<'a, E>(&'a mut self, _: E, _: Self) -> boolwhere
&'a mut Self: PartialEq<E>,
§Example
use cba::bait::TransformExt;
let mut v = 0usize;
if !v.cmp_exch(&mut 0, 1) {
unreachable!();
}
assert_eq!(v, 1);Sourcefn cmp_replace(&mut self, _: Self) -> boolwhere
Self: PartialEq,
fn cmp_replace(&mut self, _: Self) -> boolwhere
Self: PartialEq,
§Example
use cba::bait::TransformExt;
true.modify_if(cfg!(debug_assertions), |x| *dbg!(x));fn dbg(self) -> Selfwhere
Self: Debug,
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.