pub trait BiFunctionOnce<T, U, R> {
// Required method
fn apply(self, first: &T, second: &U) -> R;
// Provided methods
fn into_box(self) -> BoxBiFunctionOnce<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) -> BoxBiFunctionOnce<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
BiFunctionOnce trait - consuming bi-function that takes references
Defines the behavior of a consuming bi-function: computing a value of
type R from references to types T and U by taking ownership of self.
This trait is analogous to FnOnce(&T, &U) -> R.
§Type Parameters
T- The type of the first input value (borrowed)U- The type of the second input value (borrowed)R- The type of the output value
§Author
Haixing Hu
Required Methods§
Provided Methods§
Sourcefn into_box(self) -> BoxBiFunctionOnce<T, U, R>where
Self: Sized + 'static,
T: 'static,
U: 'static,
R: 'static,
fn into_box(self) -> BoxBiFunctionOnce<T, U, R>where
Self: Sized + 'static,
T: 'static,
U: 'static,
R: 'static,
Converts to BoxBiFunctionOnce
⚠️ Consumes self: The original bi-function becomes unavailable
after calling this method.
§Returns
Returns BoxBiFunctionOnce<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-function to a closure
⚠️ Consumes self: The original bi-function becomes unavailable
after calling this method.
§Returns
Returns a closure that implements FnOnce(&T, &U) -> R
Sourcefn to_box(&self) -> BoxBiFunctionOnce<T, U, R>where
Self: Clone + 'static,
T: 'static,
U: 'static,
R: 'static,
fn to_box(&self) -> BoxBiFunctionOnce<T, U, R>where
Self: Clone + 'static,
T: 'static,
U: 'static,
R: 'static,
Converts bi-function to a boxed function pointer
📌 Borrows &self: The original bi-function remains usable
after calling this method.
§Returns
Returns a boxed function pointer that implements FnOnce(&T, &U) -> R
§Examples
use prism3_function::BiFunctionOnce;
let add = |x: &i32, y: &i32| *x + *y;
let func = add.to_box();
assert_eq!(func.apply(&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-function to a closure
📌 Borrows &self: The original bi-function remains usable
after calling this method.
§Returns
Returns a closure that implements FnOnce(&T, &U) -> R
§Examples
use prism3_function::BiFunctionOnce;
let add = |x: &i32, y: &i32| *x + *y;
let func = add.to_fn();
assert_eq!(func(&20, &22), 42);