home ~ projects ~ socials

Paginate Over A Vec In Rust Using chunks

fn main() {
  let data = vec!["a", "b", "c", "d", "e", "f", "g"];
  data.chunks(2).for_each(|w| { dbg!(w); () });
}
Output:
[_active_nvim_run:3] w = [
    "a",
    "b",
]
[_active_nvim_run:3] w = [
    "c",
    "d",
]
[_active_nvim_run:3] w = [
    "e",
    "f",
]
[_active_nvim_run:3] w = [
    "g",
]
-- end of line --