Capture by Value with move
10 points
Implement make_adder, which returns a closure that adds n to whatever it's called with. The closure must outlive the function call that created it, so it needs to own n rather than borrow it — that's what the move keyword is for.
Required signature
pub fn make_adder(n: i32) -> impl Fn(i32) -> i32;
Visible tests
-
adds_correctly#[test] fn adds_correctly() { let add5 = make_adder(5); assert_eq!(add5(10), 15); }
Your solution
Log in to submit a solution.