core/char: Add comment to to_digit()
This commit is contained in:
parent
64a5172652
commit
7843e2792d
@ -122,6 +122,9 @@ pub fn is_digit(self, radix: u32) -> bool {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_digit(self, radix: u32) -> Option<u32> {
|
pub fn to_digit(self, radix: u32) -> Option<u32> {
|
||||||
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
|
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
|
||||||
|
|
||||||
|
// the code is split up here to improve execution speed for cases where
|
||||||
|
// the `radix` is constant and 10 or smaller
|
||||||
let val = if radix <= 10 {
|
let val = if radix <= 10 {
|
||||||
match self {
|
match self {
|
||||||
'0' ..= '9' => self as u32 - '0' as u32,
|
'0' ..= '9' => self as u32 - '0' as u32,
|
||||||
|
Loading…
Reference in New Issue
Block a user