pub trait Indexable<T>:
AsRef<[T]>
+ AsMut<[T]>
+ Index<usize, Output = T>
+ IndexMut<usize>
+ Index<Range<usize>, Output = [T]>
+ IndexMut<Range<usize>>
+ Index<RangeFrom<usize>, Output = [T]>
+ IndexMut<RangeFrom<usize>>
+ Index<RangeTo<usize>, Output = [T]>
+ IndexMut<RangeTo<usize>>
+ Index<RangeInclusive<usize>, Output = [T]>
+ IndexMut<RangeInclusive<usize>>
+ Index<RangeToInclusive<usize>, Output = [T]>
+ IndexMut<RangeToInclusive<usize>>
+ Index<RangeFull, Output = [T]>
+ IndexMut<RangeFull> { }Expand description
Slice-like container providing direct indexed and range-based access.
Indexable represents types whose contents can be accessed using the full
family of Rust slice indexing operations (single index and ranges). This
enables algorithms that rely on positional access rather than iteration.
However, these operations follow the standard Rust indexing semantics and
may panic if the index or range is out of bounds. For this reason,
Indexable should only be used when the caller can guarantee that bounds
are valid or when the structure’s invariants ensure safe indexing.
In most runtime logic, iteration-based abstractions such as Buffer
or Collection are preferred since they avoid panic-prone positional
access and better support deterministic runtime execution.
Indexable is therefore best suited for:
- fixed-size or strictly bounded containers
- structures where indices are validated by prior logic
- algorithms that require deterministic positional access
When combined with other runtime traits (e.g. RuntimeType, Elastic,
Delimited), the container can participate safely in deterministic runtime
computation while still exposing slice-style access semantics.
Typical implementors include:
Vec<T>- fixed-size arrays (
[T; N]) - bounded containers such as
BoundedVec<T, _>