mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-30 09:05:54 +00:00
BREAKING CHANGE: improvement: disallow leading '+' after "0x" prefix for u64 parse
This commit is contained in:
1 parent
ef40be0d53
commit
57f1fb4dc4
1 file changed
+5
-1
+5
-1
@@ -163,7 +163,11 @@ fn main() {
|
|||||||
|
|
||||||
fn parse_hex_or_int(n: &str) -> Option<u64> {
|
fn parse_hex_or_int(n: &str) -> Option<u64> {
|
||||||
if n.starts_with("0x") {
|
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 {
|
} else {
|
||||||
n.parse::<u64>().ok()
|
n.parse::<u64>().ok()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user