simplify number parsing
This commit is contained in:
parent
32d1b2b370
commit
577e2a2c78
|
@ -30,11 +30,9 @@ pub fn parse_number_with_radix<T: Num>(
|
|||
c.is_digit(base) && remaining >= 0
|
||||
})
|
||||
.collect();
|
||||
if !digits.is_empty() {
|
||||
T::from_str_radix(&digits, base).ok()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
(!digits.is_empty())
|
||||
.then(|| T::from_str_radix(&digits, base).ok())
|
||||
.flatten()
|
||||
}
|
||||
|
||||
pub fn parse_n<T: Debug, P: Tokens<Item = char>, const N: usize>(
|
||||
|
|
Loading…
Reference in a new issue