StatefulBiTransformer

Trait StatefulBiTransformer 

Source
pub trait StatefulBiTransformer<T, U, R> {
    // Required method
    fn apply(&mut self, first: T, second: U) -> R;

    // Provided methods
    fn into_box(self) -> BoxStatefulBiTransformer<T, U, R>
       where Self: Sized + 'static,
             T: 'static,
             U: 'static,
             R: 'static { ... }
    fn into_rc(self) -> RcStatefulBiTransformer<T, U, R>
       where Self: Sized + 'static,
             T: 'static,
             U: 'static,
             R: 'static { ... }
    fn into_arc(self) -> ArcStatefulBiTransformer<T, U, R>
       where Self: Sized + Send + 'static,
             T: Send + Sync + 'static,
             U: Send + Sync + 'static,
             R: Send + 'static { ... }
    fn into_fn(self) -> impl FnMut(T, U) -> R
       where Self: Sized + 'static,
             T: 'static,
             U: 'static,
             R: 'static { ... }
    fn into_once(self) -> BoxBiTransformerOnce<T, U, R>
       where Self: Sized + 'static,
             T: 'static,
             U: 'static,
             R: 'static { ... }
    fn to_box(&self) -> BoxStatefulBiTransformer<T, U, R>
       where Self: Sized + Clone + 'static,
             T: 'static,
             U: 'static,
             R: 'static { ... }
    fn to_rc(&self) -> RcStatefulBiTransformer<T, U, R>
       where Self: Sized + Clone + 'static,
             T: 'static,
             U: 'static,
             R: 'static { ... }
    fn to_arc(&self) -> ArcStatefulBiTransformer<T, U, R>
       where Self: Sized + Clone + Send + Sync + 'static,
             T: Send + Sync + 'static,
             U: Send + Sync + 'static,
             R: Send + Sync + 'static { ... }
    fn to_fn(&self) -> impl FnMut(T, U) -> R
       where Self: Sized + Clone + 'static,
             T: 'static,
             U: 'static,
             R: 'static { ... }
    fn to_once(&self) -> BoxBiTransformerOnce<T, U, R>
       where Self: Sized + Clone + 'static,
             T: 'static,
             U: 'static,
             R: 'static { ... }
}
Expand description

StatefulBiTransformer trait - transforms two values to produce a result

Defines the behavior of a bi-transformation: converting two values of types T and U to a value of type R by consuming the inputs. This is analogous to Fn(T, U) -> R in Rust’s standard library.

§Type Parameters

  • T - The type of the first input value (consumed)
  • U - The type of the second input value (consumed)
  • R - The type of the output value

§Author

Haixing Hu

Required Methods§

Source

fn apply(&mut self, first: T, second: U) -> R

Transforms two input values to produce an output value

§Parameters
  • first - The first input value to transform (consumed)
  • second - The second input value to transform (consumed)
§Returns

The transformed output value

Provided Methods§

Source

fn into_box(self) -> BoxStatefulBiTransformer<T, U, R>
where Self: Sized + 'static, T: 'static, U: 'static, R: 'static,

Converts to BoxStatefulBiTransformer

⚠️ Consumes self: The original bi-transformer becomes unavailable after calling this method.

§Default Implementation

The default implementation wraps self in a Box and creates a BoxStatefulBiTransformer. Types can override this method to provide more efficient conversions.

§Returns

Returns BoxStatefulBiTransformer<T, U, R>

Source

fn into_rc(self) -> RcStatefulBiTransformer<T, U, R>
where Self: Sized + 'static, T: 'static, U: 'static, R: 'static,

Converts to RcStatefulBiTransformer

⚠️ Consumes self: The original bi-transformer becomes unavailable after calling this method.

§Default Implementation

The default implementation wraps self in an Rc and creates an RcStatefulBiTransformer. Types can override this method to provide more efficient conversions.

§Returns

Returns RcStatefulBiTransformer<T, U, R>

Source

fn into_arc(self) -> ArcStatefulBiTransformer<T, U, R>
where Self: Sized + Send + 'static, T: Send + Sync + 'static, U: Send + Sync + 'static, R: Send + 'static,

Converts to ArcStatefulBiTransformer

⚠️ Consumes self: The original bi-transformer becomes unavailable after calling this method.

§Default Implementation

The default implementation wraps self in an Arc and creates an ArcStatefulBiTransformer. Types can override this method to provide more efficient conversions.

§Returns

Returns ArcStatefulBiTransformer<T, U, R>

Source

fn into_fn(self) -> impl FnMut(T, U) -> R
where Self: Sized + 'static, T: 'static, U: 'static, R: 'static,

Converts bi-transformer to a closure

⚠️ Consumes self: The original bi-transformer becomes unavailable after calling this method.

§Default Implementation

The default implementation creates a closure that captures self and calls its apply method. Types can override this method to provide more efficient conversions.

§Returns

Returns a closure that implements FnMut(T, U) -> R

Source

fn into_once(self) -> BoxBiTransformerOnce<T, U, R>
where Self: Sized + 'static, T: 'static, U: 'static, R: 'static,

Converts to BoxBiTransformerOnce

⚠️ Consumes self: The original bi-transformer becomes unavailable after calling this method.

§Default Implementation

The default implementation wraps self in a Box and creates a BoxBiTransformerOnce. Types can override this method to provide more efficient conversions.

§Returns

Returns BoxBiTransformerOnce<T, U, R>

Source

fn to_box(&self) -> BoxStatefulBiTransformer<T, U, R>
where Self: Sized + Clone + 'static, T: 'static, U: 'static, R: 'static,

Non-consuming conversion to BoxStatefulBiTransformer using &self.

Default implementation clones self and delegates to into_box.

Source

fn to_rc(&self) -> RcStatefulBiTransformer<T, U, R>
where Self: Sized + Clone + 'static, T: 'static, U: 'static, R: 'static,

Non-consuming conversion to RcStatefulBiTransformer using &self.

Default implementation clones self and delegates to into_rc.

Source

fn to_arc(&self) -> ArcStatefulBiTransformer<T, U, R>
where Self: Sized + Clone + Send + Sync + 'static, T: Send + Sync + 'static, U: Send + Sync + 'static, R: Send + Sync + 'static,

Non-consuming conversion to ArcStatefulBiTransformer using &self.

Default implementation clones self and delegates to into_arc.

Source

fn to_fn(&self) -> impl FnMut(T, U) -> R
where Self: Sized + Clone + 'static, T: 'static, U: 'static, R: 'static,

Non-consuming conversion to a boxed function using &self.

Returns a Box<dyn FnMut(T, U) -> R> that clones self and calls apply inside the boxed closure.

Source

fn to_once(&self) -> BoxBiTransformerOnce<T, U, R>
where Self: Sized + Clone + 'static, T: 'static, U: 'static, R: 'static,

Non-consuming conversion to BoxBiTransformerOnce using &self.

Default implementation clones self and delegates to into_once.

Implementors§

Source§

impl<T, U, R> StatefulBiTransformer<T, U, R> for ArcStatefulBiTransformer<T, U, R>

Source§

impl<T, U, R> StatefulBiTransformer<T, U, R> for BoxStatefulBiTransformer<T, U, R>

Source§

impl<T, U, R> StatefulBiTransformer<T, U, R> for RcStatefulBiTransformer<T, U, R>

Source§

impl<T, U, R, F> StatefulBiTransformer<T, U, R> for F
where F: FnMut(T, U) -> R, T: 'static, U: 'static, R: 'static,