A 3-pointer iterator that moves out of a Vec<T> or Box<[T]>
Why?
If you want to iterate and move items out of a Vec<T>, you'd normally call
.into_iter(), producing a vec::IntoIter iterator. (Note: The
upcoming IntoIterator impl
for Box<[T]> also uses vec::IntoIter.) This is fine for most use cases.
However, storing a large collection of vec::IntoIter iterators might be
suboptimal for memory usage. This is because vec::IntoIter is represented as 4
pointers, which is one more than strictly necessary if all you want is iterating
in one direction.
This crate provides a SmallIter type, which is represented as 3 pointers. In
exchange for this smaller size, this type doesn't implement
DoubleEndedIterator.
Usage
The IntoSmallIterExt trait provides the into_small_iter() method, which
allows you to produce SmallIter iterators from a Vec<T> or a Box<[T]>.
use IntoSmallIterExt;
let v = vec!;
let iter = v.into_small_iter;
let v2: = iter.collect;
assert_eq!;
The benefits of the space savings of this crate is most likely to be relevant if you store a bunch of iterators.
use ;
let v = vec!;
let mut iters: = v.into_iter.map.collect;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;