std-method

Iterator::size_hint — remaining length bounds

Inspect a lower bound and optional upper bound on the number of items remaining. An unknown upper bound is None. A hint is not a proof of memory safety and should not justify unchecked writes. Expected stdout (not executed): (4, Some(4)) (3, Some(3)) Common mistake: Treating the upper bound as the exact length.

Formal Syntax & Structure

rust syntaxrust
fn size_hint(&self) -> (usize, Option<usize>)

Working Example

Example Snippetrust
fn main() {    let mut ids = 10..14;    println!("{:?}", ids.size_hint());    ids.next();    println!("{:?}", ids.size_hint());}
Rust Reference