From b8c20f4f8c1217c28993a277340f4cac47f5a277 Mon Sep 17 00:00:00 2001 From: Chris Mounce Date: Wed, 28 Jan 2026 14:45:21 -0800 Subject: [PATCH] Change bind indexes to be `NonZero` --- src/zzt/parse.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/zzt/parse.rs b/src/zzt/parse.rs index 50a2b8e..6c9c21c 100644 --- a/src/zzt/parse.rs +++ b/src/zzt/parse.rs @@ -26,7 +26,7 @@ pub enum Program { /// The stat owns its own code. Own(String), /// The stat is bound to another stat (index into the stats list). - Bound(u16), + Bound(NonZero), } impl Default for Program { @@ -359,7 +359,10 @@ impl Stat { let (input, program) = if length < 0 { // Negative length means bound to another stat - (input, Program::Bound((-length) as u16)) + ( + input, + Program::Bound(NonZero::new((-length) as u16).unwrap()), + ) } else { // Positive length means own code let (input, code_bytes) = take(length as usize)(input)?; @@ -408,7 +411,7 @@ impl Stat { match &self.program { Program::Bound(index) => { - result.push_i16(-(*index as i16)); + result.push_i16(-(index.get() as i16)); result.push_padding(8); } Program::Own(code) => {