pub fn new<'a, Brand, A, B>(
f: impl 'a + Fn(A) -> B,
) -> <Brand as Function>::Of<'a, A, B>where
Brand: Function,Expand description
Creates a new function wrapper.
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall a b. (a -> b) -> a -> b
§Type Parameters
'a: The lifetime of the function and its captured data.Brand: The brand of the function wrapper.A: The input type of the function.B: The output type of the function.
§Parameters
f: The closure to wrap._: The input value to the function.
§Returns
The wrapped function.
§Examples
use fp_library::{brands::*, functions::*};
let f = fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
assert_eq!(f(5), 10);