From: Jacob Casper Date: Tue, 16 Jan 2024 03:04:06 +0000 (-0600) Subject: Fix a panic in as_field_spec X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;h=702a6da606eb25b829465c45772dde3f8b8ee61a;p=mix.git 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. --- 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 }, ], };