eval
Log in

A Mutable Counter Closure

10 points

Implement make_counter, which returns a closure that starts at 0 and returns one higher each time it's called. Because the closure mutates state it owns between calls, its return type is impl FnMut() -> i32, not impl Fn() -> i32.

Required signature

pub fn make_counter() -> impl FnMut() -> i32;

Visible tests

Your solution

Log in to submit a solution.