Batched collections iteration?


I’ve recently read this short blog post:

It looks a bit like the opposite of this paper:

So is it worth adding a segmented API to the iteration of Rust stdlib HashSet, HashMap, BTreeSet, BTreeMap?


Rust’s design helps a bunch here in that internal iteration can already choose to use nested loops if that’s better for the structure in question. For example,

I think I’d always rather refactor a for loop to .for_each() over refactoring to nested-for-using-batched. (Or try_for_each, in 1.27, if I need early-exit.)

Also, I think Rust’s HashMap doesn’t use buckets, so doesn’t actually need batched/segmented iteration…