Clear the clippy warnings that were failing CI before this branch
🐳 Android image / Build and push (push) Successful in 1s
Build and test / android-image (push) Successful in 1s
Build and test / Desktop (Linux) (push) Failing after 9m6s
Build and test / Layer separation (push) Successful in 26s
Traceability / Requirement traces (push) Failing after 23s
Build and test / Android (aarch64) (push) Failing after 22m38s

Nothing here is film simulation. These are lints that fail master today,
under the -D warnings CI runs with, mostly from a toolchain that learned
new ones rather than from anybody's code -- `is_multiple_of` and the
derivable `Default` did not exist as lints when this was written.

They are fixed rather than allowed, and by hand rather than by trusting
`cargo clippy --fix` wholesale: its automatic pass split a derive in two
and left a stray blank line, which is the sort of thing that is correct
and still wrong to commit.

The four that needed a decision rather than a rewrite:

  - The distance transform's inner loop writes through its iterator now.
    `q` stays, because it is the position the parabola is evaluated at as
    well as the index it is written to -- the lint is about the write.
  - `to_source` and `to_proto` take `self` by value. Their receiver is
    `Copy`, so this is the same machine code and the honest signature.
  - The export path's return type is five levels deep and now has a name,
    plus a line saying why the `Option` wraps the `Result`: `None` is
    cancellation, which is not a failure and has no error to report.
  - A test fills a range instead of looping over one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-25 22:35:02 +02:00
co-authored by Claude Opus 5
parent 3b5952769b
commit 56978fdf35
11 changed files with 145 additions and 124 deletions
+8 -7
View File
@@ -183,12 +183,15 @@ fn transform(f: &[f32], out: &mut [f32], v: &mut [usize], z: &mut [f32]) {
}
k = 0;
for q in 0..n {
// `q` is both the position and the value the parabola is evaluated at, so
// it stays; what changes is that the write goes through the iterator
// rather than re-indexing `out` on every step.
for (q, slot) in out.iter_mut().enumerate().take(n) {
while z[k + 1] < q as f32 {
k += 1;
}
let p = v[k];
out[q] = (q as f32 - p as f32).powi(2) + f[p];
*slot = (q as f32 - p as f32).powi(2) + f[p];
}
}
@@ -414,13 +417,13 @@ mod tests {
#[test]
fn an_empty_mask_is_everywhere_outside() {
let d = signed_distance(&vec![0u8; 16], 4, 4, 128);
let d = signed_distance(&[0u8; 16], 4, 4, 128);
assert!(d.iter().all(|&v| v < 0.0), "no pixel can be inside");
}
#[test]
fn a_full_mask_is_everywhere_inside() {
let d = signed_distance(&vec![255u8; 16], 4, 4, 128);
let d = signed_distance(&[255u8; 16], 4, 4, 128);
assert!(d.iter().all(|&v| v > 0.0), "no pixel can be outside");
}
@@ -548,9 +551,7 @@ mod tests {
// M5: masks reach the sidecar as indices, so the field they are shaped
// by has to be reproducible.
let mut m = vec![0u8; 64];
for i in 20..30 {
m[i] = 255;
}
m[20..30].fill(255);
let a = signed_distance(&m, 8, 8, 128);
let b = signed_distance(&m, 8, 8, 128);
assert_eq!(a, b);
+1 -1
View File
@@ -410,7 +410,7 @@ mod tests {
#[test]
fn a_wrong_sized_mask_is_an_error_not_a_panic() {
let f = field();
let err = Membership::compute(&f, &[&vec![0.0; 3]], &PriorOptions::default()).unwrap_err();
let err = Membership::compute(&f, &[&[0.0; 3]], &PriorOptions::default()).unwrap_err();
assert_eq!(
err,
MembershipError::MaskSize {
+4 -9
View File
@@ -56,13 +56,14 @@ const DETECTION_STRIDE: usize = 6 + PROTOTYPES;
const PROTO_STRIDE: usize = 4;
/// How the image is presented to a fixed-shape graph.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub enum Tiling {
/// One inference over the whole frame, letterboxed into the square input.
///
/// The default, and the right default: a photographic subject is usually
/// *large* in frame, which is the case whole-image inference handles best
/// and the case tiling helps least.
#[default]
Whole,
/// Cover the frame with overlapping fixed-size windows.
///
@@ -77,12 +78,6 @@ pub enum Tiling {
Grid { overlap: f32 },
}
impl Default for Tiling {
fn default() -> Self {
Self::Whole
}
}
/// How the semantic pass is tuned.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SemanticOptions {
@@ -515,7 +510,7 @@ impl Letterbox {
}
/// Input-space box back to source pixels.
fn to_source(&self, x0: f32, y0: f32, x1: f32, y1: f32, w: &Window) -> (f32, f32, f32, f32) {
fn to_source(self, x0: f32, y0: f32, x1: f32, y1: f32, w: &Window) -> (f32, f32, f32, f32) {
(
(x0 - self.pad_x) / self.scale + w.x,
(y0 - self.pad_y) / self.scale + w.y,
@@ -525,7 +520,7 @@ impl Letterbox {
}
/// Source pixel to prototype-grid coordinates.
fn to_proto(&self, sx: f32, sy: f32, w: &Window) -> (f32, f32) {
fn to_proto(self, sx: f32, sy: f32, w: &Window) -> (f32, f32) {
(
((sx - w.x) * self.scale + self.pad_x) / PROTO_STRIDE as f32,
((sy - w.y) * self.scale + self.pad_y) / PROTO_STRIDE as f32,