operator

Rust <: compare against an upper limit

Use `<` for strict ordering, such as checking whether a quantity is below a limit. Equality is excluded. Expected output (not executed): true false Why: Seven is below ten; ten is not below itself. Common mistake: Do not write `0 < used < capacity`; combine separate comparisons with `&&`. Advanced connection: `std::cmp::PartialOrd::lt`.

Formal Syntax & Structure

rust syntaxrust
a < b

Working Example

Example Snippetrust
fn main() {    let used = 7;    let capacity = 10;    println!("{}", used < capacity);    println!("{}", capacity < capacity);}
Rust Reference