std-method

slice::rchunks_exact

Visit full-size groups beginning at the end; an incomplete prefix is exposed through remainder. Size zero panics. Expected stdout (not executed): [1] [[4, 5], [2, 3]] Common mistake: Assuming the incomplete group is a suffix as with chunks_exact.

Formal Syntax & Structure

rust syntaxrust
slice.rchunks_exact(size)

Working Example

Example Snippetrust
fn main() {    let data = [1, 2, 3, 4, 5];    let mut groups = data.rchunks_exact(2);    println!("{:?}", groups.remainder());    println!("{:?}", groups.by_ref().collect::<Vec<_>>());}
Rust Reference