The IndexRange<T> trait allows you to use standard Rust range syntax (e.g., .., a.., ..b, or a..b) in operations that require defining a range of indices. The trait provides methods to retrieve the start (inclusive) and end (exclusive) bounds of the range.
Supported range types via the IndexRange trait:
RangeFull (..): Both start() and end() return None.RangeFrom<T> (a..): start() returns Some(a), end() returns None.RangeTo<T> (..b): start() returns None, end() returns Some(b).Range<T> (a..b): start() returns Some(a), end() returns Some(b).
use core::ops::{Range, RangeFrom, RangeFull, RangeTo};
// Example of how the trait behaves with different range syntaxes:
let full = ..;
let from = 5..;
let to = ..10;
let both = 5..10;
// The trait provides access to bounds:
// full.start() -> None, full.end() -> None
// from.start() -> Some(5), from.end() -> None
// to.start() -> None, to.end() -> Some(10)
// both.start() -> Some(5), both.end() -> Some(10)