core/char: Add comment to to_digit()

This commit is contained in:
Tobias Bieniek 2018-11-14 11:26:00 +01:00
parent 64a5172652
commit 7843e2792d

View File

@ -122,6 +122,9 @@ pub fn is_digit(self, radix: u32) -> bool {
#[inline]
pub fn to_digit(self, radix: u32) -> Option<u32> {
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 {
match self {
'0' ..= '9' => self as u32 - '0' as u32,