Reverse a groupby slice : is that the best way?


Please have a look at the working PG :

I want to reverse the order of a group by, to decrease toward the beginning of a vector.

The solution I found is to use itertools, but I wanted to know if I missed a pure std way to do it.


Itertools' function rev just fowards to std's Iterator::rev:


fn main() {
    let mut v: Vec<u32> = vec![1, 1, 2, 3, 3, 3, 4, 5, 5, 6];

    for i in v.group_by(|x, y| x == y).rev() {
            println!("> {:?}", i);
1 Like

I misplaced the rev before the group_by when I tried. Stupid me.

Okay! Thanks!