Function range_chunks_rev

Source
fn range_chunks_rev(
    start: Bound<usize>,
    end: usize,
    chunk_size: usize,
) -> impl Iterator<Item = Range<usize>>
Expand description

Break a range into fixed-size chunks, starting from the end and moving towards the start.

While the chunks are yielded in reverse order, from end to start, each individual chunk is in the usual ascending order. That is, the first chunk ends with end and the last chunk starts with start.

Note that unlike range_chunks_rev, which accepts any range and yields an infinite iterator if the range has no upper bound, this function requires there to be a defined upper bound, otherwise we don’t know where the reversed iterator should start. The end bound given here is inclusive; i.e. the end of the first chunk yielded by the stream will be exactly end.