From f137e9df9a8bf9ced198f8faa7177bd1ca242798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Legrand?= Date: Sat, 31 Oct 2026 20:29:10 +0100 Subject: [PATCH] fix(pathops): M2.1: keep Fenwick indices Rust 1.95 compatible --- crates/pathops/src/budget.rs | 4 ++-- crates/pathops/src/budget_tests.rs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/pathops/src/budget.rs b/crates/pathops/src/budget.rs index ff6f9cab4..714611ceb 100644 --- a/crates/pathops/src/budget.rs +++ b/crates/pathops/src/budget.rs @@ -112,7 +112,7 @@ impl Fenwick { let mut i = rank + 1; while let Some(c) = self.0.get_mut(i) { *c += by; - i += i.isolate_lowest_one(); + i += i & i.wrapping_neg(); } } @@ -123,7 +123,7 @@ impl Fenwick { && let Some(c) = self.0.get(i) { n += c; - i -= i.isolate_lowest_one(); + i -= i & i.wrapping_neg(); } u64::try_from(n).unwrap_or(0) } diff --git a/crates/pathops/src/budget_tests.rs b/crates/pathops/src/budget_tests.rs index b53b5545d..a55e58e85 100644 --- a/crates/pathops/src/budget_tests.rs +++ b/crates/pathops/src/budget_tests.rs @@ -93,3 +93,9 @@ fn a_fold_stops_once_it_has_swept_its_budget() { assert_eq!(steps, MAX_FOLD_SEGMENTS / 100_004); assert_eq!(budget.spend(&BezPath::new(), &BezPath::new()), Err(PathOpsError::TooComplex), "spent stays spent"); } + +#[test] +fn overlapping_rectangle_bounds_count_self_and_cross_pairs() { + let shapes = rects([Rect::new(0.0, 0.0, 2.0, 2.0), Rect::new(1.0, 1.0, 3.0, 3.0), Rect::new(4.0, 4.0, 5.0, 5.0)]); + assert_eq!(complexity([&shapes]), Some(Complexity { segments: 12, crossings: 14 })); +}