operator

Rust ..: exclusive ranges and slice bounds

A bounded `start..end` range includes the start and excludes the end. It is useful for iteration and indexing a sequence. Expected output (not executed): 2 3 4 Why: The loop stops before page five. Common mistake: Do not assume `..` includes the last endpoint; a reversed integer range is empty rather than descending automatically. Advanced connection: Constructs `std::ops::Range`.

Formal Syntax & Structure

rust syntaxrust
start..end

Working Example

Example Snippetrust
fn main() {    for page in 2..5 {        println!("{page}");    }}
Rust Reference