Crate const_size_flatten
source ·Expand description
Versions of FlatMap
and Flatten
that know their inner iterators’ size in advance.
Note that core
& std
already provide this functionality for some types through a hack using specialization.
This crate’s contribution is that the trait ConstSizeIntoIterator
is public and the functionality is therefore extensible.
To use, just use const_size_flatten::IteratorExtension
.
Structs
- A version of
FlatMap
that knows its inner iterators’ size in advance, and can produce accurate lower and upper bounds usingIterator::size_hint
. This iterator does not requireExactSizeIterator
for the inner iterators. It can nonetheless provide an accurate length viaIterator::size_hint
if they implement it. This iterator does not implementExactSizeIterator
, even if the inner iterators implement it. This is because the nesting may cause the size to exceedusize::MAX
. - A version of
Flatten
that knows its inner iterators’ size in advance, and can produce accurate lower and upper bounds usingIterator::size_hint
. This iterator does not requireExactSizeIterator
for the inner iterators. It can nonetheless provide an accurate length viaIterator::size_hint
if they implement it. This iterator does not implementExactSizeIterator
, even if the inner iterators implement it. This is because the nesting may cause the size to exceedusize::MAX
.
Traits
- Implementors of this trait promise that all iterators they produce always produce the same number of elements. This number is given by the associated constant
SIZE
. Note that this trait should not be implemented forIterator
s, since they can be iterated through, which changes the amount of elements they produce. - Convenience
trait
that allows you to constructConstSizeFlatten
andConstSizeFlatMap
. This trait is sealed, you cannot implement it.