pub trait BiTransformerOnce<T, U, R> {
// Required method
fn apply(self, first: T, second: U) -> R;
// Provided methods
fn into_box(self) -> BoxBiTransformerOnce<T, U, R>
where Self: Sized + 'static,
T: 'static,
U: 'static,
R: 'static { ... }
fn into_fn(self) -> impl FnOnce(T, U) -> R
where Self: Sized + 'static,
T: 'static,
U: 'static,
R: 'static { ... }
fn to_box(&self) -> BoxBiTransformerOnce<T, U, R>
where Self: Clone + 'static,
T: 'static,
U: 'static,
R: 'static { ... }
fn to_fn(&self) -> impl FnOnce(T, U) -> R
where Self: Clone + 'static,
T: 'static,
U: 'static,
R: 'static { ... }
}Expand description
BiTransformerOnce trait - consuming bi-transformation that takes ownership
Defines the behavior of a consuming bi-transformer: converting two values of
types T and U to a value of type R by taking ownership of self and
both inputs. This trait is analogous to FnOnce(T, U) -> R.
§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) -> BoxBiTransformerOnce<T, U, R>where
Self: Sized + 'static,
T: 'static,
U: 'static,
R: 'static,
fn into_box(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.
§Returns
Returns BoxBiTransformerOnce<T, U, R>
Sourcefn into_fn(self) -> impl FnOnce(T, U) -> Rwhere
Self: Sized + 'static,
T: 'static,
U: 'static,
R: 'static,
fn into_fn(self) -> impl FnOnce(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.
§Returns
Returns a closure that implements FnOnce(T, U) -> R
Sourcefn to_box(&self) -> BoxBiTransformerOnce<T, U, R>where
Self: Clone + 'static,
T: 'static,
U: 'static,
R: 'static,
fn to_box(&self) -> BoxBiTransformerOnce<T, U, R>where
Self: Clone + 'static,
T: 'static,
U: 'static,
R: 'static,
Converts bi-transformer to a boxed function pointer
📌 Borrows &self: The original bi-transformer remains usable
after calling this method.
§Returns
Returns a boxed function pointer that implements FnOnce(T, U) -> R
§Examples
use prism3_function::BiTransformerOnce;
let add = |x: i32, y: i32| x + y;
let func = add.to_fn();
assert_eq!(func(20, 22), 42);Sourcefn to_fn(&self) -> impl FnOnce(T, U) -> Rwhere
Self: Clone + 'static,
T: 'static,
U: 'static,
R: 'static,
fn to_fn(&self) -> impl FnOnce(T, U) -> Rwhere
Self: Clone + 'static,
T: 'static,
U: 'static,
R: 'static,
Converts bi-transformer to a closure
📌 Borrows &self: The original bi-transformer remains usable
after calling this method.
§Returns
Returns a closure that implements FnOnce(T, U) -> R
§Examples
use prism3_function::BiTransformerOnce;
let add = |x: i32, y: i32| x + y;
let func = add.to_fn();
assert_eq!(func(20, 22), 42);