Modern Apps git

← Modern-Apps.git

measure_cv: fix clippy warnings

Commit
dadaeaafd5f0d818d36e728e27bf66dd257587f7
Author
Vayun Mathur <[email protected]>
When
2026-11-17 14:08 UTC (18 days ago)
Parents
8625ee6
Migrate the JNI bindings off the deprecated Env array helpers
to the jni 0.22 typed-array API (JByteArray::len/get_region and
JDoubleArray::set_region), dropping the now-redundant cast.
Rewrite the corner-bounds assert with Range::contains.

Verified: cargo check -p measure_cv --all-targets and
cargo clippy -p measure_cv --all-targets report no crate
warnings; cargo test -p measure_cv passes.

Diff

measure/src/main/rust/src/corners.rs
diff --git a/measure/src/main/rust/src/corners.rs b/measure/src/main/rust/src/corners.rsindex 427ff81905..b47a60c312 100644--- a/measure/src/main/rust/src/corners.rs+++ b/measure/src/main/rust/src/corners.rs@@ -168,7 +168,7 @@ mod tests {         assert!(pts.len() >= 20, "expected many corners, got {}", pts.len());         assert!(pts.len() <= MAX_CORNERS);         for &(x, y) in &pts {-            assert!(x >= 0.0 && x < 320.0 && y >= 0.0 && y < 240.0);+            assert!((0.0..320.0).contains(&x) && (0.0..240.0).contains(&y));         }         // Sub-pixel refinement should move some points off the integer grid         // (its accuracy is asserted directly by the square-corner test).
measure/src/main/rust/src/lib.rs
diff --git a/measure/src/main/rust/src/lib.rs b/measure/src/main/rust/src/lib.rsindex 71bec343c9..dce66617a3 100644--- a/measure/src/main/rust/src/lib.rs+++ b/measure/src/main/rust/src/lib.rs@@ -266,15 +266,15 @@ mod jni_bindings {             if w == 0 || h == 0 || stride < w {                 return Ok(make_double_array(env, &[]));             }-            let len = match env.get_array_length(&y_plane) {-                Ok(l) => l as usize,+            let len = match y_plane.len(env) {+                Ok(l) => l,                 Err(_) => return Ok(make_double_array(env, &[])),             };             if len < stride * (h - 1) + w {                 return Ok(make_double_array(env, &[]));             }             let mut buf = vec![0i8; len];-            if env.get_byte_array_region(&y_plane, 0, &mut buf).is_err() {+            if y_plane.get_region(env, 0, &mut buf).is_err() {                 return Ok(make_double_array(env, &[]));             }             let mut gray = Gray::new(w, h);@@ -327,7 +327,7 @@ mod jni_bindings {             Ok(a) => a,             Err(_) => return std::ptr::null_mut(),         };-        if !vals.is_empty() && env.set_double_array_region(&arr, 0, vals).is_err() {+        if !vals.is_empty() && arr.set_region(env, 0, vals).is_err() {             return std::ptr::null_mut();         }         arr.into_raw()