BiTransformerOnce

Trait BiTransformerOnce 

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

Source

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

Transforms two input values, consuming self and both inputs

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

The transformed output value

Provided Methods§

Source

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>

Source

fn into_fn(self) -> impl FnOnce(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.

§Returns

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

Source

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);
Source

fn to_fn(&self) -> impl FnOnce(T, U) -> R
where 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);

Implementors§

Source§

impl<F, T, U, R> BiTransformerOnce<T, U, R> for F
where F: FnOnce(T, U) -> R,

Source§

impl<T, U, R> BiTransformerOnce<T, U, R> for BoxBiTransformerOnce<T, U, R>