CONCEPT LIBRARY

Bounds checking

Checking whether an index belongs to an array or slice.

Overview

For an array of length L, a valid zero-based index satisfies 0 ≤ i < L. Safe Rust indexing panics on an invalid index. A compiler can remove a check when analysis proves it redundant. The type usize alone does not prove the upper bound.

Further reading

Related concepts

Related papers

Referenced in issues