Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give VirtualListVector a lifetime? #85

Open
MinusGix opened this issue Aug 11, 2023 · 0 comments
Open

Give VirtualListVector a lifetime? #85

MinusGix opened this issue Aug 11, 2023 · 0 comments

Comments

@MinusGix
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant