Trait std::iter::TrustedLen
source[−]pub unsafe trait TrustedLen: Iterator { }
Expand description
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
. In that case, the lower bound must be
usize::MAX
, resulting in an Iterator::size_hint()
of
(usize::MAX, None)
.
The iterator must produce exactly the number of elements it reported or diverge before reaching the end.
Safety
This trait must only be implemented when the contract is upheld. Consumers
of this trait must inspect Iterator::size_hint()
’s upper bound.
Implementors
1.36.0 · source