refactor: extract "0x" literal into HEX_PREFIX

This commit is contained in:
Erich Gubler authored and David Peter committed 2020-05-28 18:43:53 +02:00
1 parent 57f1fb4dc4
commit 3b3889967c
1 file changed
+4 -2
+4 -2
View File
@@ -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;
}