pub unsafe trait TrustedLen: Iterator { }Expand description
Trait for all types which have a known upper-bound.
Functions that receive a TrustedLen iterator can assume that it’s size_hint is exact,
and can pre-allocate memory, unroll loops, or otherwise optimize their implementations
accordingly.
§Safety
The type which implements this trait must provide an exact Some upper-bound for its
size_hint method. Failure to do so can trigger undefined behavior in users of the trait.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".