diff options
Diffstat (limited to 'src/hitomezashi.rs')
-rw-r--r-- | src/hitomezashi.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/hitomezashi.rs b/src/hitomezashi.rs index d8a8c42..02baff7 100644 --- a/src/hitomezashi.rs +++ b/src/hitomezashi.rs @@ -33,10 +33,7 @@ fn print_square(is_transparent: bool) { } pub fn hitomezashi(width: usize, height: usize, skew: Option<f64>) { - let skew: f64 = match skew { - Some(n) => n, - None => 0.5, - }; + let skew: f64 = skew.unwrap_or(0.5); let mut rng = rand::thread_rng(); let brn = Bernoulli::new(skew).unwrap(); @@ -79,7 +76,7 @@ pub fn hitomezashi(width: usize, height: usize, skew: Option<f64>) { println!(); // height-1 because the first row has already been printed - for row in 0..(height - 1) { + for row_bit in row_bits.iter().take(height - 1) { /* each square in each successive row is derived from the square above it. the row bits * represent whether there's a stitch between the two squares. if there's a stitch, the * squares are different, otherwise they are the same. */ @@ -87,7 +84,7 @@ pub fn hitomezashi(width: usize, height: usize, skew: Option<f64>) { .iter_mut() .zip(alt_bits.iter()) .for_each(|(x1, &x2)| { - *x1 ^= x2 ^ row_bits[row]; + *x1 ^= x2 ^ row_bit; print_square(*x1); }); |