It would be nice to implement the Collection trait on types that do not hold the data directly, but rather construct it at iteration time. As an example, a set of numbers in the range 0..64 may be represented as a bit field, with an iterator going through the bits and tracking the index. This iterator would return owned numbers, not references, thus not satisfying the requirements for Collection::Iter.
A potential solution would be to somehow adapt the Collection trait to allow any kind of items, or to offer some form of API to easily convert between a Collection with owned iterator and one with some sort of cache that has an iterator on references.
It would be nice to implement the
Collectiontrait on types that do not hold the data directly, but rather construct it at iteration time. As an example, a set of numbers in the range 0..64 may be represented as a bit field, with an iterator going through the bits and tracking the index. This iterator would return owned numbers, not references, thus not satisfying the requirements forCollection::Iter.A potential solution would be to somehow adapt the Collection trait to allow any kind of items, or to offer some form of API to easily convert between a Collection with owned iterator and one with some sort of cache that has an iterator on references.