Open florian1345 opened 1 year ago
Problem: We need to keep the domain Item
type in addition to the actual, technical item type of the iterator, as we want assertions to behave equally whether the iterator iterates over references, owned values, or whatever. This may cause some additional complexity in implementing Collection
. Can we maybe use default values or something similar?
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 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.