mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 18:04:13 +00:00
No need to check the assert all the time.
This commit is contained in:
parent
d9b3ff7d34
commit
bf02d1ea5f
@ -343,10 +343,10 @@ impl char {
|
|||||||
without modifying the original"]
|
without modifying the original"]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn to_digit(self, radix: u32) -> Option<u32> {
|
pub const fn to_digit(self, radix: u32) -> Option<u32> {
|
||||||
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
|
|
||||||
// If not a digit, a number greater than radix will be created.
|
// If not a digit, a number greater than radix will be created.
|
||||||
let mut digit = (self as u32).wrapping_sub('0' as u32);
|
let mut digit = (self as u32).wrapping_sub('0' as u32);
|
||||||
if radix > 10 {
|
if radix > 10 {
|
||||||
|
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
|
||||||
if digit < 10 {
|
if digit < 10 {
|
||||||
return Some(digit);
|
return Some(digit);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user