I'm trying to write a function that curries a function of two variables into a function-valued function of one variable.
When the types involved are all simple, there's no problem:
fn curry1(f: fn(i32, i32) -> i32) -> Box<Fn(i32) -> Box<Fn(i32) -> i32>> {
Box::new(move |x| Box::new(move |y| f(x, y)))
}
Once I try to make any of the parameters generic I run into lifetime issues that I can't solve:
fn curry2<Z>(f: fn(i32, i32) -> Z) -> Box<Fn(i32) -> Box<Fn(i32) -> Z>> {
Box::new(move |x| Box::new(move |y| f(x, y)))
}
the parameter type Z may not live long enough to satisfy its required lifetime bounds
How can I properly describe and annotate the relevant lifetimes?