mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-28 08:05:52 +00:00
refactor: extract "0x" literal into HEX_PREFIX
This commit is contained in:
1 parent
57f1fb4dc4
commit
3b3889967c
1 file changed
+4
-2
+4
-2
@@ -162,8 +162,10 @@ fn main() {
|
||||
}
|
||||
|
||||
fn parse_hex_or_int(n: &str) -> Option<u64> {
|
||||
if n.starts_with("0x") {
|
||||
let n = n.trim_start_matches("0x");
|
||||
const HEX_PREFIX: &'static str = "0x";
|
||||
|
||||
if n.starts_with(HEX_PREFIX) {
|
||||
let n = n.trim_start_matches(HEX_PREFIX);
|
||||
if n.chars().next() == Some('+') {
|
||||
return None;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user