Clippy (as_chunks) and rustfmt after the community PR batch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Brandon ThomasandClaude Opus 5.5 committed 2026-10-10 14:50:54 -04:00
1 parent 27d6bf2548
commit 06f742c787
3 files changed
+6 -35

No files matched your search

+1 -6
View File
@@ -261,12 +261,7 @@ impl Ellipse {
// candidate parameters (opposite sides of the ellipse).
let minor = self.minor();
let mut bounds = Bounds2::from_points([self.at_param(self.start), self.at_param(self.end)]);
for angle in [
minor.x.atan2(self.major.x),
minor.x.atan2(self.major.x) + PI,
minor.y.atan2(self.major.y),
minor.y.atan2(self.major.y) + PI,
] {
for angle in [minor.x.atan2(self.major.x), minor.x.atan2(self.major.x) + PI, minor.y.atan2(self.major.y), minor.y.atan2(self.major.y) + PI] {
if angle_in_sweep(angle, self.start, self.end) {
bounds.add(self.at_param(angle));
}
+4 -28
View File
@@ -187,12 +187,7 @@ fn circle_three_points_preserves_large_world_coordinates() {
// A unit circle near a survey coordinate. The absolute-square formula suffers
// catastrophic cancellation and returns a center tens of millions of units away.
let origin = 1.0e12;
let c = Circle::from_3_points(
Vec2::new(origin + 1.0, origin),
Vec2::new(origin, origin + 1.0),
Vec2::new(origin - 1.0, origin),
)
.unwrap();
let c = Circle::from_3_points(Vec2::new(origin + 1.0, origin), Vec2::new(origin, origin + 1.0), Vec2::new(origin - 1.0, origin)).unwrap();
assert!(c.center.near(Vec2::new(origin, origin), 1e-3), "{c:?}");
assert!((c.radius - 1.0).abs() < 1e-3, "{c:?}");
}
@@ -223,13 +218,7 @@ fn ellipse_bounds_find_analytic_extrema() {
#[test]
fn elliptical_arc_bounds_exclude_extrema_outside_the_sweep() {
let e = Ellipse {
center: Vec2::ZERO,
major: Vec2::new(3.0, 4.0),
ratio: 0.5,
start: 0.0,
end: PI / 4.0,
};
let e = Ellipse { center: Vec2::ZERO, major: Vec2::new(3.0, 4.0), ratio: 0.5, start: 0.0, end: PI / 4.0 };
let bounds = e.bounds();
assert!((bounds.max.x - 3.0).abs() < 1e-12);
assert!((bounds.min.x - e.at_param(e.end).x).abs() < 1e-12);
@@ -250,15 +239,7 @@ fn polyline_area_is_exact_for_bulge_segments() {
#[test]
fn polyline_area_is_stable_far_from_the_origin() {
let o = 1.0e12;
let p = Polyline::from_points(
&[
Vec2::new(o, o),
Vec2::new(o + 10.0, o),
Vec2::new(o + 10.0, o + 10.0),
Vec2::new(o, o + 10.0),
],
true,
);
let p = Polyline::from_points(&[Vec2::new(o, o), Vec2::new(o + 10.0, o), Vec2::new(o + 10.0, o + 10.0), Vec2::new(o, o + 10.0)], true);
assert!((p.area() - 100.0).abs() < 1e-12, "{}", p.area());
// An open polyline's measured area retains the implicit straight closing edge.
let mut open = p;
@@ -269,12 +250,7 @@ fn polyline_area_is_stable_far_from_the_origin() {
#[test]
fn shoelace_preserves_small_polygon_area_at_large_coordinates() {
let o = 1.0e12;
let corners = [
Vec2::new(o, o),
Vec2::new(o + 10.0, o),
Vec2::new(o + 10.0, o + 10.0),
Vec2::new(o, o + 10.0),
];
let corners = [Vec2::new(o, o), Vec2::new(o + 10.0, o), Vec2::new(o + 10.0, o + 10.0), Vec2::new(o, o + 10.0)];
assert_eq!(shoelace(&corners), 100.0);
assert_eq!(shoelace(&corners.iter().rev().copied().collect::<Vec<_>>()), -100.0);
}
+1 -1
View File
@@ -393,7 +393,7 @@ pub(crate) fn layer_colors_xdata(colors: &[(String, Color)]) -> Vec<Tag> {
pub(crate) fn read_layer_colors(tags: &[Tag]) -> Vec<(String, Color)> {
let list = xdata_list(xdata(tags, APP), "VPCOLORS");
let names: Vec<String> = list.iter().take(MAX_XDATA_ITEMS * 2).filter(|t| t.code == 1000).map(Tag::str).collect();
names.chunks_exact(2).filter_map(|p| Some((p.first()?.clone(), Color::parse(p.get(1)?)?))).collect()
names.as_chunks::<2>().0.iter().filter_map(|[name, color]| Some((name.clone(), Color::parse(color)?))).collect()
}
const POINT_NAMES: [&str; 5] = ["defpt", "p13", "p14", "p15", "p16"];