From e3946801ed3c1068077be169f04770c8b38a00b66399172837e7e0b60f065e3d Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Sat, 20 Apr 2024 00:00:00 +0000 Subject: Make alt_bits initialization more explicit --- src/hitomezashi.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/hitomezashi.rs b/src/hitomezashi.rs index b39cace..6fb785e 100644 --- a/src/hitomezashi.rs +++ b/src/hitomezashi.rs @@ -55,8 +55,10 @@ pub fn hitomezashi(width: usize, height: usize, skew: Option) { let mut alt_bits: Vec = Vec::with_capacity(width); - for col in 0..alt_bits.capacity() { - alt_bits.push(col % 2 == 1); + let mut alternator: bool = false; + for _ in 0..alt_bits.capacity() { + alt_bits.push(alternator); + alternator = !alternator; } // each new row of the pattern depends on the bits directly above it -- cgit v1.2.3