aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
Diffstat (limited to 'src/math')
-rw-r--r--src/math/polygon/triangulate.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/math/polygon/triangulate.rs b/src/math/polygon/triangulate.rs
index 4c7d952..8a18cd7 100644
--- a/src/math/polygon/triangulate.rs
+++ b/src/math/polygon/triangulate.rs
@@ -75,10 +75,13 @@ where
*/
while polygon.corners.len() > 3 {
// Find the ear with the highest index.
- let ear = flags
- .iter()
- .rposition(|&x| (x & FLAG_EAR) != 0)
- .expect("Polygon has more than three vertices, but no ear.");
+ let ear = match flags.iter().rposition(|&x| (x & FLAG_EAR) != 0) {
+ Some(pos) => pos,
+ None => panic!(
+ "Polygon has more than three vertices, but no ear: {:?}",
+ polygon
+ ),
+ };
// Add the ear's triangle to the list.
{