1use std::error::Error; 2 3pub fn parse_num(value: &str) -> Result<u64, Box<dyn Error>> { 4 let val = if value.trim().starts_with("0x") { 5 u64::from_str_radix(&value[2..], 16)? 6 } else { 7 u64::from_str_radix(value, 10)? 8 }; 9 Ok(val) 10}