range_chunks_aligned_rev

Function range_chunks_aligned_rev 

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

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

Each chunk is of size alignment, and starts on a multiple of alignment (that is, the lower bound an exclusive upper bound of each chunk are multiples of alignment), with the possible exception of the first chunk (the last chunk in numerical order, which may be small) and the last (which may be misaligned and small).

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_aligned, 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.