I need an open-ended decreasing integer iterator in Rust. (..=n).rev()
does not work. The closest I've found is std::iter::successors(Some(n), |n| Some(n - 1))
, which seems needlessly convoluted.
Is there a clearer way to express this notion of a numerically decreasing iterator?
It's not exactly open-ended, but you could use the minimum value for whatever integer type you're targeting:
(i64::MIN..=n).rev()