The previous problem with this was, that I tried returning "Some((Ref<i32>, _))" from the lambda. That caused the compiler to complain about the lifetime of the `current` value, since I tried passing on the Ref instead of the encapsulated value.
in task2, RefCell is used since the passed state in 'scan' seems to be immutable, although it shouldn't.