From 57f1fb4dc463be1e155cb6ab219fada56524ff2d Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Mon, 18 May 2020 13:53:46 -0600 Subject: [PATCH] BREAKING CHANGE: improvement: disallow leading `'+'` after `"0x"` prefix for u64 parse --- src/bin/hexyl.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 10c411a..e85ac59 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -163,7 +163,11 @@ fn main() { fn parse_hex_or_int(n: &str) -> Option { 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::().ok() }