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
FlatMapthat knows its inner iterators’ size in advance, and can produce accurate lower and upper bounds usingIterator::size_hint. This iterator does not requireExactSizeIteratorfor the inner iterators. It can nonetheless provide an accurate length viaIterator::size_hintif 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
Flattenthat knows its inner iterators’ size in advance, and can produce accurate lower and upper bounds usingIterator::size_hint. This iterator does not requireExactSizeIteratorfor the inner iterators. It can nonetheless provide an accurate length viaIterator::size_hintif 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 forIterators, since they can be iterated through, which changes the amount of elements they produce. - Iterator
Extension - Convenience
traitthat allows you to constructConstSizeFlattenandConstSizeFlatMap. This trait is sealed, you cannot implement it.
Functions§
- const_
size_ flat_ map - Construct a
ConstSizeFlatMapfrom anIntoIterator(which includesIterators). - const_
size_ flatten - Construct a
ConstSizeFlattenfrom anIntoIterator(which includesIterators).