Skip to main content

representable_len

Function representable_len 

Source
fn representable_len(start: usize, item_len: usize, len: usize) -> usize
Expand description

The number of items whose offsets are representable.

Item i sits at start + i * item_len, and walking the array computes one offset past the last item, so this is the largest len for which start + len * item_len does not overflow. Establishing it once up front lets iteration be a plain add per step.

An array built by ComputedArray::new is already within this bound: its last offset is range.end, which had to be a valid index into data.