-
Notifications
You must be signed in to change notification settings - Fork 321
Suggestion: map an iterator of indexes to their values in a slice #743
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
Comments
This seems entirely fine, though? .map(|i| &slice[i]) Generally anything that's "this particular map" needs to be incredibly common to be worth adding. (See #726 (comment) for a recent example of something not being accepted.) |
Hi there, I guess that would be covered by #447. |
What's wrong with
And EDIT: I guess when range is not a range but a more complex iterator of indexes? |
Yep, that was the intention. That was a bad example on my part. For an iterator like, say,
Totally fair. I usually use slices for this too, but yesterday I was iterating over a range of let buf: VecDeque<T> = ...;
let range: Range<usize> = ...;
for value in range.map(|i| &buf[i]) {
// ...
} This doesn't come up a lot for me either, I understand it not being common enough for this crate |
It makes me think of
|
I've run into a pattern that I'm surprised isn't an iterator method or extension already (or if it is, I haven't found it):
An
map_index
extension could be added for this, like:The text was updated successfully, but these errors were encountered: