I am trying to lazily map over an iterator with a closure that uses a
This is not permitted by the compiler with the error message "captured variable cannot escape
FnMut closure body".
I have created an example at the Playground that demonstrates roughly what I would like to do. My non-working attempt is the (commented) function
countdown_repeat_mut in lines 26--34.
I know that the functions in the playground example look quite artificial and that you would never write such a
countdown_mut in real life, but it is a reasonable simplification of the actual problem I'm trying to solve.
Is this actually possible what I am aiming for? If so, how?
Please keep in mind that I am aiming to create a lazy iterator, so I am not allowed to call
collect() when producing the iterator in