From 702a6da606eb25b829465c45772dde3f8b8ee61a Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Mon, 15 Jan 2024 21:04:06 -0600 Subject: [PATCH] Fix a panic in as_field_spec When field specs got implemented correctly 0 stopped representing the "special case" where we read a word without modifications. I just need to make note that the F byte should be 5 for now in that case. Anything that is unrepresentable should probably _also_ represent that case, so 63 would be a fine number as well. --- src/machine.rs | 4 ++-- src/main.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index fdecd33..f4ae649 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -64,9 +64,9 @@ impl Word { } else { l_clamp = l_clamp - 1; } - let r_clamp = (fs.r - 1) % 5; + let r_clamp = fs.r % 6; let mut bytes = [MixBit::default(); 5]; - for n in l_clamp..=r_clamp { + for n in l_clamp..r_clamp { bytes[n] = self.bytes[n]; } Word { sign, bytes } diff --git a/src/main.rs b/src/main.rs index 345f81e..24c2c61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ fn main() { MixBit { v: 0 }, MixBit { v: 0 }, MixBit { v: 0 }, - MixBit { v: 29 }, + MixBit { v: 5 }, MixBit { v: 8 }, ], }; -- 2.20.1