diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-09-15 18:03:36 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-09-15 18:03:36 +0200 |
| commit | 21489a0a1b465e89d73b86689dc4b8a2a40610f9 (patch) | |
| tree | 4afd3e0a9878d39f02e8cedeb73d21635ba76cd8 | |
| parent | 01bb4fee8c45caee757b3bdc5432fd88dbcdfca3 (diff) | |
| download | tools.nes-21489a0a1b465e89d73b86689dc4b8a2a40610f9.tar.gz tools.nes-21489a0a1b465e89d73b86689dc4b8a2a40610f9.zip | |
xixanta: simplify evaluate_hexadecimal()
The 'size' variable can be initialized directly from the value we get
from the match statement below. I was probably thinking more on the
style of C, but the latest Rust stable channel complained about this.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
| -rw-r--r-- | lib/xixanta/src/assembler.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 04ecaef..afd8429 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -2119,30 +2119,28 @@ impl<'a> Assembler<'a> { fn evaluate_hexadecimal(&mut self, node: &PNode) -> Result<Bundle, Error> { let mut chars = node.value.value.chars(); let mut bytes = [0, 0, 0]; - let size: u8; - - match node.value.value.len() { + let size: u8 = match node.value.value.len() { 1 => { bytes[0] = self.char_to_hex(chars.next(), node)?; - size = 1; + 1 } 2 => { bytes[0] = self.char_to_hex(chars.next(), node)? * 16; bytes[0] += self.char_to_hex(chars.next(), node)?; - size = 1; + 1 } 3 => { bytes[1] = self.char_to_hex(chars.next(), node)?; bytes[0] = self.char_to_hex(chars.next(), node)? * 16; bytes[0] += self.char_to_hex(chars.next(), node)?; - size = 2; + 2 } 4 => { bytes[1] = self.char_to_hex(chars.next(), node)? * 16; bytes[1] += self.char_to_hex(chars.next(), node)?; bytes[0] = self.char_to_hex(chars.next(), node)? * 16; bytes[0] += self.char_to_hex(chars.next(), node)?; - size = 2; + 2 } _ => { if self.evaluate_variable(node).is_ok() { @@ -2165,7 +2163,7 @@ impl<'a> Assembler<'a> { global: false, }); } - } + }; Ok(Bundle { bytes, |
