From c1c902b4b534254b04bb0bd04c2c26a98103fa9f Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 10 Nov 2021 00:36:03 +0100 Subject: fix overblown numeric handling The ergonomics of these changed quite a while back. --- src/vtcol.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/vtcol.rs') diff --git a/src/vtcol.rs b/src/vtcol.rs index f7b3529..3cae3f2 100644 --- a/src/vtcol.rs +++ b/src/vtcol.rs @@ -325,10 +325,10 @@ impl Palette fn nibble_of_char(chr: u8) -> u8 { - match chr as char { - '0'..='9' => chr - '0' as u8, - 'a'..='f' => chr - 'a' as u8 + 10, - 'A'..='F' => chr - 'A' as u8 + 10, + match chr { + b'0'..=b'9' => chr - b'0', + b'a'..=b'f' => chr - b'a' + 10, + b'A'..=b'F' => chr - b'A' + 10, _ => 0, } } @@ -357,11 +357,11 @@ impl Palette for def in colors.iter() { let (r, g, b) = rgb_of_hex_triplet(*def); - pal[idx + 0] = r; + pal[idx ] = r; pal[idx + 1] = g; pal[idx + 2] = b; //println!(">> {} -> {:X} {:X} {:X}", def, r, g, b); - idx = idx + 3; + idx += 3; } Palette { colors: pal } @@ -405,7 +405,7 @@ impl Palette let col = &line[off..(off + RAW_COLEXPR_SIZE)]; let (r, g, b) = rgb_of_hex_triplet(col); - pal[pal_idx + 0] = r; + pal[pal_idx ] = r; pal[pal_idx + 1] = g; pal[pal_idx + 2] = b; pal_idx = (pal_idx + 3) % PALETTE_BYTES; @@ -453,10 +453,10 @@ impl fmt::Display for Palette { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mut i: usize = 0; + let mut i = 0; while i < PALETTE_BYTES { let _ = write!(f, "{}", if i == 0 { "(" } else { "\n " }); - let r = self.colors[i + 0]; + let r = self.colors[i ]; let g = self.colors[i + 1]; let b = self.colors[i + 2]; let _ = write!( @@ -464,7 +464,7 @@ impl fmt::Display for Palette "((r 0x{:02.X}) (g 0x{:02.X}) (b 0x{:02.x}))", r, g, b ); - i = i + 3; + i += 3; } writeln!(f, ")") } @@ -476,7 +476,7 @@ impl fmt::Debug for Palette { let mut i: u8 = 0_u8; while (i as usize) < PALETTE_BYTES { - let r = self.colors[i as usize + 0]; + let r = self.colors[i as usize ]; let g = self.colors[i as usize + 1]; let b = self.colors[i as usize + 2]; let _ = writeln!( @@ -487,7 +487,7 @@ impl fmt::Debug for Palette g, b ); - i = i + 3_u8; + i += 3_u8; } std::result::Result::Ok(()) } -- cgit v1.2.3