#no-std #iterator

no-std const-size-flatten

Flatten and FlatMap with constant inner iterator size

9 releases

0.4.4 Mar 7, 2023
0.4.3 Mar 7, 2023
0.3.0 Mar 4, 2023
0.2.0 Mar 3, 2023
0.1.2 Mar 2, 2023

#1210 in Rust patterns

32 downloads per month

MIT license

13KB
298 lines

Flatten and FlatMap with constant inner iterator size

This Rust package provides ConstSizeFlatten and ConstSizeFlatMap which make use of the also provided ConstSizeIntoIterator to know how many items they will yield.

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.


lib.rs:

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::ConstSizeFlattenIteratorExtension.

No runtime deps