Skip to main content

flip

Function flip 

Source
pub fn flip<A, B, C>(f: impl Fn(A, B) -> C) -> impl Fn(B, A) -> C
Expand description

Function.flip — swap the first two arguments of a two-argument function.

use id_effect::func::flip;
let sub = |a: i32, b: i32| a - b;
let flipped = flip(sub);
assert_eq!(flipped(3, 10), 10 - 3);