Skip to content

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

Conversation

Liewyec
Copy link
Contributor

@Liewyec Liewyec commented Jan 20, 2024

fixes #395

@Liewyec Liewyec force-pushed the feature/improve-iterator-for-file-suppression branch 2 times, most recently from 772f0ef to 0cb2478 Compare January 20, 2024 12:52
@Liewyec Liewyec changed the title improve iterator for files suppression WIP: improve iterator for files suppression Jan 20, 2024
Comment on lines 984 to 987
.enumerate()
.filter(|(pos, _)| *pos < start || *pos >= end)
.take(start)
.skip(count)
.map(|(_, path)| path)

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code.

@Liewyec Liewyec force-pushed the feature/improve-iterator-for-file-suppression branch from 0cb2478 to 599492a Compare January 21, 2024 08:24
@Liewyec Liewyec changed the title WIP: improve iterator for files suppression Improve iterator for files suppression Jan 21, 2024
.filter(|(pos, _)| *pos < start || *pos >= end)
.map(|(_, path)| path)
{
for path in files.iter().skip(start).take(count) {
Copy link
Member

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!

@antoyo antoyo merged commit 2a36f58 into rust-lang:master Feb 1, 2024
@antoyo
Copy link
Contributor

antoyo commented Feb 1, 2024

Thanks for your contribution!

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

Successfully merging this pull request may close these issues.

Improve iterator for files suppression
4 participants