floem
floem copied to clipboard
Give VirtualListVector a lifetime?
It would be good to give VirtualListVector
a lifetime for the iterator.
Ex:
If we wanted to implement VirtualListVector
for [T; N]
where T: Clone
, it might be desirable to have the iterator not clone the entire array at once in case it is large. So we'd have ItemIterator
be std::iter::Copied<std::slice::Iter<'_, T>>
.. but we can't specify any lifetime other than static which just won't work.
Ex:
If we wanted to implement VirtualListVector
for Vec<T>
where T: Clone
then we could avoid a whole new heap allocation via letting the iterator hold a reference to it
Similarly, even im::Vector
is having to clone the sliced part to an entire new vector when it is used.
I haven't taken a close look at whether this would cause any problems.
It might also be more desirable to return a &T
instead? So a borrowed iterator.