From d26500251d8db7032fe9ffb2a2dc56e2538e2110 Mon Sep 17 00:00:00 2001 From: Raymon Zutekouw <40148684+Raymonzut@users.noreply.github.com> Date: Fri, 7 Jan 2022 11:43:23 +0100 Subject: [PATCH] Parse constants unsigned --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index c89e9bc..14dfbd5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,15 +53,15 @@ fn extract_operand(statement: Pair) -> &str { line } -fn parse_constant(text: &str) -> Result { +fn parse_constant(text: &str) -> Result { if text.starts_with("\"") { let c = text.chars().nth(1).unwrap(); - Ok(c as i32) + Ok(c as u32) } else if text.starts_with("0x") { let without_prefix = text.trim_start_matches("0x"); - i32::from_str_radix(without_prefix, 16) + u32::from_str_radix(without_prefix, 16) } else { - i32::from_str_radix(text, 10) + u32::from_str_radix(text, 10) } }