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§
Provided Methods§
Sourcefn into_box(self) -> BoxStatefulBiTransformer<T, U, R>where
Self: Sized + 'static,
T: 'static,
U: 'static,
R: 'static,
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>
Sourcefn into_rc(self) -> RcStatefulBiTransformer<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,
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>
Sourcefn into_arc(self) -> ArcStatefulBiTransformer<T, U, R>
fn into_arc(self) -> ArcStatefulBiTransformer<T, U, R>
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>
Sourcefn into_fn(self) -> impl FnMut(T, U) -> Rwhere
Self: Sized + 'static,
T: 'static,
U: 'static,
R: 'static,
fn into_fn(self) -> impl FnMut(T, U) -> Rwhere
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
Sourcefn into_once(self) -> BoxBiTransformerOnce<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,
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>
Sourcefn to_box(&self) -> BoxStatefulBiTransformer<T, U, R>
fn to_box(&self) -> BoxStatefulBiTransformer<T, U, R>
Non-consuming conversion to BoxStatefulBiTransformer using &self.
Default implementation clones self and delegates to into_box.
Sourcefn to_rc(&self) -> RcStatefulBiTransformer<T, U, R>
fn to_rc(&self) -> RcStatefulBiTransformer<T, U, R>
Non-consuming conversion to RcStatefulBiTransformer using &self.
Default implementation clones self and delegates to into_rc.
Sourcefn to_arc(&self) -> ArcStatefulBiTransformer<T, U, R>
fn to_arc(&self) -> ArcStatefulBiTransformer<T, U, R>
Non-consuming conversion to ArcStatefulBiTransformer using &self.
Default implementation clones self and delegates to into_arc.
Sourcefn to_fn(&self) -> impl FnMut(T, U) -> R
fn to_fn(&self) -> impl FnMut(T, U) -> R
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.
Sourcefn to_once(&self) -> BoxBiTransformerOnce<T, U, R>
fn to_once(&self) -> BoxBiTransformerOnce<T, U, R>
Non-consuming conversion to BoxBiTransformerOnce using &self.
Default implementation clones self and delegates to into_once.