Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Fix clippy after upstream merge (art style test, Fenwick step, pencil bool)

nrq6993-a11ya0b038e9e2c9
diff --git a/crates/eps/src/import/ai/style.rs b/crates/eps/src/import/ai/style.rs
index 91aa02475..389b0657e 100644
--- a/crates/eps/src/import/ai/style.rs
+++ b/crates/eps/src/import/ai/style.rs
@@ -827,8 +827,7 @@ mod tests {
#[test]
fn hostile_stroke_paint_flags_ignore_short_operands() {
- let mut f = Filter::default();
- f.paints = (true, true);
+ let mut f = Filter { paints: (true, true), ..Filter::default() };
paint_op(&mut f, "Xd", &[V::Num(1.0)]);
assert_eq!(f.paints, (true, true));
paint_op(&mut f, "Xd", &[V::Num(0.0), V::Num(1.0)]);
diff --git a/crates/pathops/src/budget.rs b/crates/pathops/src/budget.rs
index ab7ead8a6..01559ce8a 100644
--- a/crates/pathops/src/budget.rs
+++ b/crates/pathops/src/budget.rs
@@ -15,14 +15,18 @@ pub const MAX_SEGMENT_PAIRS: usize = 1 << 22;
/// Fenwick tree of counts over its slots.
struct Counts(Vec<isize>);
-// `isolate_lowest_one` is still unstable in Rust 1.96, and the workspace builds on 1.95 (rust-version).
-#[allow(clippy::manual_isolate_lowest_one)]
+#[inline]
+fn fenwick_step(i: usize) -> usize {
+ // Same as `i.isolate_lowest_one()`; that API is still unstable on the workspace MSRV.
+ 1 << i.trailing_zeros()
+}
+
impl Counts {
fn add(&mut self, slot: usize, d: isize) {
let mut i = slot + 1;
while let Some(c) = self.0.get_mut(i) {
*c += d;
- i += i & i.wrapping_neg();
+ i += fenwick_step(i);
}
}
@@ -31,7 +35,7 @@ impl Counts {
let (mut i, mut s) = (end.min(self.0.len().saturating_sub(1)), 0);
while i > 0 {
s += self.0.get(i).copied().unwrap_or(0);
- i -= i & i.wrapping_neg();
+ i -= fenwick_step(i);
}
s
}