-
Notifications
You must be signed in to change notification settings - Fork 13k
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
fn windows
: do not panic for a size of 0
#87767
Conversation
This comment has been minimized.
This comment has been minimized.
This changes the (stable) @rfcbot merge |
Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
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 can't seem to tick my box.
Same here. I can edit the comment and put an |
In the meantime, @rfcbot reviewed should work I believe (obviously not for me as I'm not on the list). |
uh, my impls actually don't just work as I expected 😅 I've introduced the following bugs: I forgot that we can have zst slices of let x = &[(); usize::MAX];
x.array_windows::<N>(); // this now causes an integer overflow for any `N` because of my impl
x.array_windows::<0>(); // this has an unrepresentable size My changes to fn test_windows_zero() {
let v: &[i32] = &[0, 1];
let mut iter = v.windows(0);
assert_eq!(iter.next(), Some(&[][..]));
assert_eq!(iter.next(), Some(&[][..]));
assert_eq!(iter.next(), Some(&[][..])); // causes a panic here
assert_eq!(iter.next(), None);
} While the second one can be fixed by modifying the implementation, the fact that we can have an unrepresentable iterator length seems undesirable. Will go ahead and add these problems as tests and close this PR. 😅 |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@rfcbot cancel |
@yaahc proposal cancelled. |
add `windows` count test cc rust-lang#87767
I understand
fn windows
as the following,so this method seems well defined for a size of 0 to me.
r? @m-ou-se