Range types implement half-open and inclusive ranges, enabling slicing, iteration, and bounds checking in Rust core.
// Source: https://github.com/rust-lang/rust | License: Apache-2.0 | Copyright The Rust Project Contributors
// Provided via justclaw.it.com; keep this notice with the code.
//! # Replacement range types
//!
//! The types within this module are meant to replace the legacy `Range`,
//! `RangeInclusive`, `RangeToInclusive` and `RangeFrom` types in a future edition.
//!
//! ```
//! use core::range::{Range, RangeFrom, RangeInclusive, RangeToInclusive};
//!
//! let arr = [0, 1, 2, 3, 4];
//! assert_eq!(arr[ .. ], [0, 1, 2, 3, 4]);
//! assert_eq!(arr[ .. 3 ], [0, 1, 2 ]);
//! assert_eq!(arr[RangeToInclusive::from( ..=3)], [0, 1, 2, 3 ]);
//! assert_eq!(arr[ RangeFrom::from(1.. )], [ 1, 2, 3, 4]);
//! assert_eq!(arr[ Range:
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key