[<<][rust][>>][..]
Tue Mar 5 09:32:45 EST 2019

Iterators and Specs

When a separate wrapper IntoIterator object is necessary, make sure
that the Iterator that is generated does not include a reference to
the wrapper spec.  In practice it appears to be hard to keep that
wrapper around long enough on the stack, so either move/copy it into
the Iterator, or just copy over fields that are necessary.

The more general context is that it is necessary to have both these
traits:

- Iterator: iteration state consumed during iteration

- IntoIterator: container object that can pruduce many Iterator

Typically, more general objects can be wrapped in a struct with the
sole purpose of implementing IntoIterator.  This wrapper is often
temporary, so don't include a reference to this wrapper in the
Iterator instance.  Copy over data, or copy/move the wrapper in its
entirety.





[Reply][About]
[<<][rust][>>][..]