From 76b89fb7ea9fed087ea56abe7c0f735a38e1d5d8444ce2ffc42d8cde58a1929f Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Sat, 20 Apr 2024 00:00:00 +0000 Subject: Lint code with cargo clippy --- src/hitomezashi.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') 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) { - 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) { 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) { .iter_mut() .zip(alt_bits.iter()) .for_each(|(x1, &x2)| { - *x1 ^= x2 ^ row_bits[row]; + *x1 ^= x2 ^ row_bit; print_square(*x1); }); -- cgit v1.2.3