BREAKING CHANGE: improvement: disallow leading '+' after "0x" prefix for u64 parse

This commit is contained in:
Erich Gubler authored and David Peter committed 2020-05-28 18:43:53 +02:00
1 parent ef40be0d53
commit 57f1fb4dc4
1 file changed
+5 -1
+5 -1
View File
@@ -163,7 +163,11 @@ fn main() {
fn parse_hex_or_int(n: &str) -> Option<u64> {
if n.starts_with("0x") {
u64::from_str_radix(n.trim_start_matches("0x"), 16).ok()
let n = n.trim_start_matches("0x");
if n.chars().next() == Some('+') {
return None;
}
u64::from_str_radix(n, 16).ok()
} else {
n.parse::<u64>().ok()
}