Macro rust2fun::curry2

source ·
macro_rules! curry2 {
    ($f:expr) => { ... };
}
Expand description

Curry a function of two arguments. The first argument is applied to the function. The second argument is returned as a closure. The returned closure can be applied to the second argument. The result is the same as applying the function to both arguments.

Example

use rust2fun::prelude::*;

let g = curry2!(Option::map);

let actual = g(Some(1))(|x| x + 1);
assert_eq!(Some(2), actual);