The Iterator trait has been stable in Rust since 1.0, but the generator syntax
is currently unstable. This document will assume that generators are created
with the gen keyword, but that's for illustrative purposes only.
Has a notion of successor and predecessor operations.
trusted len †
Reports an accurate length using size_hint.
trusted step
Upholds all invariants of Step.
double-ended
Is able to yield elements from both ends.
exact size †
Knows its exact length.
fused
Always continues to yield None when exhausted.
† The difference between TrustedLen and ExactSizeIterator is that
TrustedLen is marked as unsafe to implement while ExactSizeIterator is
marked as safe to implement. This means that if TrustedLen is implemented,
you can rely on it for safety purposes, while with ExactSizeIterator you
cannot.