range

Function range 

Source
pub fn range(total: usize, worker_index: u16, worker_count: u16) -> Range<usize>
Expand description

Divide 0..total into worker_count contiguous chunks and return the chunk owned by worker_index. Distribution handles remainders by giving the first total % worker_count workers one extra item.

This is the right choice for most workloads: the union of all workers covers 0..total exactly, and chunk sizes differ by at most one. For algorithms that require every worker to process the exact same number of items (and want to fail loudly otherwise), see range_even.