aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Johnson <nick@nicholasjohnson.ch>2024-04-20 00:00:00 +0000
committerNicholas Johnson <nick@nicholasjohnson.ch>2024-04-20 00:00:00 +0000
commit76b89fb7ea9fed087ea56abe7c0f735a38e1d5d8444ce2ffc42d8cde58a1929f (patch)
treea64b436242f823e831986358246e8b514b6e4e68fa459a6fca1c51251c27e6de
parent2c269b15728ef78e1694e4acc8e62c9ae5702e6d680514f6d70bc051b709c970 (diff)
downloadhitomezashi-rs-76b89fb7ea9fed087ea56abe7c0f735a38e1d5d8444ce2ffc42d8cde58a1929f.tar.gz
hitomezashi-rs-76b89fb7ea9fed087ea56abe7c0f735a38e1d5d8444ce2ffc42d8cde58a1929f.zip
Lint code with cargo clippy
-rw-r--r--src/hitomezashi.rs9
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);
});