-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
replace match on unchecked_sub with unwrap_or_default #150262
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
base: main
Are you sure you want to change the base?
Conversation
6fbdca3 to
0fda856
Compare
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.
That seems like a good change to me, but unfortunately I can't r+ it since this is a library change
r? scottmcm
library/core/src/slice/iter.rs
Outdated
| Some(sum) => sum, | ||
| None => 0, | ||
| }; | ||
| let start = end.checked_sub(self.chunk_size).unwrap_or_default(); |
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.
| let start = end.checked_sub(self.chunk_size).unwrap_or_default(); | |
| let start = end.saturating_sub(self.chunk_size); |
wouldn't this be even better?
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.
Yes, that's correct, and I'm now using that.
0fda856 to
fd29ce0
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
|
This comment has been minimized.
This comment has been minimized.
fd29ce0 to
16b219a
Compare
Continuation of #146436
r? @joboet