Skip to main content

TransformExt

Trait TransformExt 

Source
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§

Source

fn transform<Q>(self, _: impl FnOnce(Self) -> Q) -> Q
where Self: Sized,

Source

fn transform_if(self, _: bool, _: impl FnOnce(Self) -> Self) -> Self
where Self: Sized,

§Example
Table::new(rows, widths.to_vec())
    .block(block)
    .transform_if(
        true,
        |t| t.style(style),
    )
Source

fn modify<Q>(self, _: impl FnOnce(&mut Self) -> Q) -> Self
where Self: Sized,

Source

fn modify_if<Q>(self, _: bool, _: impl FnOnce(&mut Self) -> Q) -> Self
where Self: Sized,

§Example
use cba::bait::TransformExt;

true.modify_if(cfg!(debug_assertions), |x| *dbg!(x));
Source

fn cmp_exch<'a, E>(&'a mut self, _: E, _: Self) -> bool
where &'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);
Source

fn cmp_replace(&mut self, _: Self) -> bool
where Self: PartialEq,

§Example
use cba::bait::TransformExt;

true.modify_if(cfg!(debug_assertions), |x| *dbg!(x));
Source

fn dbg(self) -> Self
where 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.

Implementors§

Source§

impl<T> TransformExt for T