keyword

Rust in: connect a for pattern to its iterable

In a for loop, `in` separates the receiving pattern from the expression supplying values. It is part of the loop syntax, not a standalone membership test. Expected output: Seat 1 Seat 2 Seat 3 Why: The range supplies 1, 2 and 3; the upper endpoint is excluded. Common mistake: Do not interpret in as a general Boolean containment operator.

Formal Syntax & Structure

rust syntaxrust
for value in iterable { statements }

Working Example

Example Snippetrust
fn main() {    for seat in 1..4 {        println!("Seat {seat}");    }}
Rust Reference