Skip to content

Commit

Permalink
Use wrapping sub
Browse files Browse the repository at this point in the history
Co-authored-by: Mara <m-ou.se@m-ou.se>
  • Loading branch information
gilescope and m-ou-se committed Feb 15, 2021
1 parent 845c14d commit 17e238d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/core/src/char/methods.rs
Expand Up @@ -337,7 +337,7 @@ impl char {
// the `radix` is constant and 10 or smaller
let val = if likely(radix <= 10) {
// If not a digit, a number greater than radix will be created.
self as u32 ^ ASCII_DIGIT_MASK
(self as u32).wrapping_sub('0' as u32)
} else {
match self {
'0'..='9' => self as u32 - '0' as u32,
Expand Down

0 comments on commit 17e238d

Please sign in to comment.