Is there a way to have closures call themselves recursively, e.g.:
fn main() {
let recurse = |x: i32| {
println!("{}", x);
let x_next = x + 1;
if x < 10 {
recurse(x_next); // commenting this line will build
}
x_next;
};
recurse(1);
}
Is there a way to workaround the closure not being defined in the closure body?