Skip to content

Commit f9597ed

Browse files
committed
fix: resolve clippy needless_range_loop warning in matrix multiplication
Use iterator with enumerate() instead of range-based indexing to satisfy clippy::needless_range_loop lint.
1 parent f8d0fc2 commit f9597ed

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/math/lucas_series.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ pub fn dynamic_lucas_number_logn(n: u32) -> u32 {
5555
fn matrix_multiply(a: [[u32; 2]; 2], b: [[u32; 2]; 2]) -> [[u32; 2]; 2] {
5656
let mut result = [[0u32; 2]; 2];
5757

58-
for i in 0..2 {
58+
for (i, a_row) in a.iter().enumerate() {
5959
for j in 0..2 {
60-
for k in 0..2 {
61-
result[i][j] = result[i][j].wrapping_add(a[i][k].wrapping_mul(b[k][j]));
60+
for (k, &a_ik) in a_row.iter().enumerate() {
61+
result[i][j] = result[i][j].wrapping_add(a_ik.wrapping_mul(b[k][j]));
6262
}
6363
}
6464
}

0 commit comments

Comments
 (0)