-
Notifications
You must be signed in to change notification settings - Fork 80
Improve iterator for files suppression #416
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
Improve iterator for files suppression #416
Conversation
772f0ef
to
0cb2478
Compare
build_system/src/test.rs
Outdated
.enumerate() | ||
.filter(|(pos, _)| *pos < start || *pos >= end) | ||
.take(start) | ||
.skip(count) | ||
.map(|(_, path)| path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
files.iter().take(start).skip(count)
you don't need enumerate and map anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked in the issue, but let repeat it here: I do not think this can be done with skip and take, because the filter if I understand it correctly yields items from beginning of the files, skips some in the middle and then possibly yields additional items from end. And I do not know how to do this with take and skip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the original code might be wrong. You probably want .skip(start).take(count)
, though.
The code is supposed to take contiguous elements: that's why I think it might be wrong. Please use .skip(start).take(count)
and I'll check if this is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code.
0cb2478
to
599492a
Compare
.filter(|(pos, _)| *pos < start || *pos >= end) | ||
.map(|(_, path)| path) | ||
{ | ||
for path in files.iter().skip(start).take(count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for the improvement!
Thanks for your contribution! |
fixes #395