pub fn pipe<A, B>(a: A, f: impl FnOnce(A) -> B) -> BExpand description
Pipes a value into a function, enabling left-to-right composition.
Free function version of Pipe::pipe. Applies f to a and
returns the result. This is equivalent to PureScript’s applyFlipped
or Haskell’s (&).
§Type Signature
forall A B. (A, A -> B) -> B
§Type Parameters
A: The type of the input value.B: The return type of the function.
§Parameters
a: The value to pipe.f: The function to apply to the value.
§Returns
The result of applying f to a.
§Examples
use fp_library::functions::*;
let result = pipe(5, |x| x + 1);
assert_eq!(result, 6);