According to a condition, I need to iterate on an array in one direction or another. So, I would like to iterate without knowing in which direction I am, that is why I want a variable storing an iterator.
Here some playground which does not compile : https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=956563a1b42c97333e35a1667ae135a7
fn main() {
let array = [1, 2 , 3];
let condition = false;
let iter = if condition {array.iter()} else {array.iter().rev()};
iter.for_each(|element| {/*Do something where the order matters*/});
}