W3cubDocs

/Rust

Trait std::iter::TrustedLen

pub unsafe trait TrustedLen: Iterator { }
🔬 This is a nightly-only experimental API. (trusted_len #37572)

An iterator that reports an accurate length using size_hint.

The iterator reports a size hint where it is either exact (lower bound is equal to upper bound), or the upper bound is None. The upper bound must only be None if the actual iterator length is larger than usize::MAX.

The iterator must produce exactly the number of elements it reported.

Safety

This trait must only be implemented when the contract is upheld. Consumers of this trait must inspect .size_hint()’s upper bound.

Implementors

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/iter/trait.TrustedLen.html