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§
- Const
Size Flat Map - 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
. - Const
Size Flatten - 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§
- Const
Size Into Iterator - 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. - Iterator
Extension - Convenience
trait
that allows you to constructConstSizeFlatten
andConstSizeFlatMap
. This trait is sealed, you cannot implement it.
Functions§
- const_
size_ flat_ map - Construct a
ConstSizeFlatMap
from anIntoIterator
(which includesIterator
s). - const_
size_ flatten - Construct a
ConstSizeFlatten
from anIntoIterator
(which includesIterator
s).