Skip to content

Commit

Permalink
stable sort
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn committed Oct 21, 2024
1 parent 5c1c3d2 commit 3dc4dfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "earcut"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
description = "A Rust port of the Earcut polygon triangulation library"
authors = ["Taku Fukada <[email protected]>", "MIERUNE Inc. <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl<T: Float> Earcut<T> {
}

self.queue
.sort_unstable_by(|(_a, ax), (_b, bx)| ax.partial_cmp(bx).unwrap_or(Ordering::Equal));
.sort_by(|(_a, ax), (_b, bx)| ax.partial_cmp(bx).unwrap_or(Ordering::Equal));

// process holes from left to right
for &(q, _) in &self.queue {
Expand Down
11 changes: 8 additions & 3 deletions tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ fn test_fixture(name: &str, num_triangles: usize, expected_deviation: f64) {
earcut.earcut(data.iter().copied(), &hole_indices, &mut triangles);

// check
assert!(triangles.len() == num_triangles * 3);
assert!(
triangles.len() == num_triangles * 3,
"{} {}",
triangles.len(),
num_triangles * 3
);
if !triangles.is_empty() {
assert!(deviation(data.iter().copied(), &hole_indices, &triangles) <= expected_deviation);
}
Expand All @@ -44,7 +49,7 @@ fn fixture_dude() {
}

#[test]
fn fixture_water() {
fn fixture_water1() {
test_fixture("water", 2482, 0.0008);
}

Expand All @@ -69,7 +74,7 @@ fn fixture_water4() {
}

#[test]
fn fixture_water_huge() {
fn fixture_water_huge1() {
test_fixture("water-huge", 5177, 0.0011);
}

Expand Down

0 comments on commit 3dc4dfd

Please sign in to comment.