Skip to content

Commit 9ed521c

Browse files
committed
style: rustfmt cleanup for fmt --all CI gate
Five locations across two files where my recent commits had lines slightly over the rustfmt width: - simd_int_ops.rs tests: 3× iterator chain reflows (.collect() onto its own line) - simd_ops.rs:505 — `array_windows` count computation broken to if/else block form - simd_ops.rs:679 / :686 — ref_add_mul_{f32,f64} test helpers reflow .iter().zip(...).map(...).collect() onto multi-line Pure whitespace / formatting; no semantic changes. 15 simd_int_ops tests + 29 simd_ops tests still pass on default v3. https://claude.ai/code/session_01HbqooFZHAjaUtFEzhA1R2u
1 parent 0eaa3ac commit 9ed521c

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

src/simd_int_ops.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,9 @@ mod tests {
641641
let n = 17;
642642
let k = 17;
643643
let a: Vec<u8> = (0..m * k).map(|i| ((i * 7 + 3) % 256) as u8).collect();
644-
let b: Vec<i8> = (0..k * n).map(|i| ((i * 11 + 5) % 256) as u8 as i8).collect();
644+
let b: Vec<i8> = (0..k * n)
645+
.map(|i| ((i * 11 + 5) % 256) as u8 as i8)
646+
.collect();
645647
let expected = ref_gemm_u8_i8(&a, &b, m, n, k);
646648
let mut c = vec![0i32; m * n];
647649
gemm_u8_i8(&a, &b, &mut c, m, n, k);
@@ -656,7 +658,9 @@ mod tests {
656658
let n = 4;
657659
let k = 8;
658660
let a = vec![255u8; m * k];
659-
let b: Vec<i8> = (0..k * n).map(|i| if i % 2 == 0 { 127i8 } else { -128i8 }).collect();
661+
let b: Vec<i8> = (0..k * n)
662+
.map(|i| if i % 2 == 0 { 127i8 } else { -128i8 })
663+
.collect();
660664
let expected = ref_gemm_u8_i8(&a, &b, m, n, k);
661665
let mut c = vec![0i32; m * n];
662666
gemm_u8_i8(&a, &b, &mut c, m, n, k);
@@ -685,7 +689,9 @@ mod tests {
685689

686690
for (m, n, k) in sizes {
687691
let a: Vec<u8> = (0..m * k).map(|i| (i % 251) as u8).collect();
688-
let b: Vec<i8> = (0..k * n).map(|i| ((i % 127) as i8).wrapping_sub(63)).collect();
692+
let b: Vec<i8> = (0..k * n)
693+
.map(|i| ((i % 127) as i8).wrapping_sub(63))
694+
.collect();
689695
let mut c_simd = vec![0i32; m * n];
690696
let mut c_scalar = vec![0i32; m * n];
691697

src/simd_ops.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,11 @@ pub fn array_chunks_checked<T, const N: usize>(data: &[T]) -> Result<impl Iterat
505505
pub fn array_windows<T, const N: usize>(data: &[T]) -> impl Iterator<Item = &[T; N]> + '_ {
506506
// Index-based iteration sidesteps `slice::windows(0)`'s panic — when
507507
// N == 0 the count below evaluates to 0 and the iterator is empty.
508-
let count = if N == 0 || data.len() < N { 0 } else { data.len() - N + 1 };
508+
let count = if N == 0 || data.len() < N {
509+
0
510+
} else {
511+
data.len() - N + 1
512+
};
509513
(0..count).map(move |i| {
510514
// `&data[i..i + N]` is exactly N elements by construction (bounds
511515
// checked once when `count` was computed). `try_into` always
@@ -679,11 +683,19 @@ mod add_mul_tests {
679683
use super::*;
680684

681685
fn ref_add_mul_f32(acc: &[f32], a: &[f32], b: &[f32]) -> Vec<f32> {
682-
acc.iter().zip(a).zip(b).map(|((&c, &x), &y)| x.mul_add(y, c)).collect()
686+
acc.iter()
687+
.zip(a)
688+
.zip(b)
689+
.map(|((&c, &x), &y)| x.mul_add(y, c))
690+
.collect()
683691
}
684692

685693
fn ref_add_mul_f64(acc: &[f64], a: &[f64], b: &[f64]) -> Vec<f64> {
686-
acc.iter().zip(a).zip(b).map(|((&c, &x), &y)| x.mul_add(y, c)).collect()
694+
acc.iter()
695+
.zip(a)
696+
.zip(b)
697+
.map(|((&c, &x), &y)| x.mul_add(y, c))
698+
.collect()
687699
}
688700

689701
#[test]

0 commit comments

Comments
 (0)