From f3733a811bb020bdffe2090f0391cecc9d976da0 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sat, 26 Oct 2024 09:28:20 -0700 Subject: [PATCH] Use float total_cmp instead of partial_cmp to get a total order. Since Rust version 1.81, sort_by will panic if the provided comparison function does not implement a total order. See https://github.com/rust/lang/rust/issues/129561 for more details. The simplest fix seems to be to use total_cmp instead of partial_cmp. --- graphics/src/damage.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/graphics/src/damage.rs b/graphics/src/damage.rs index 17d6045195..8aa427983c 100644 --- a/graphics/src/damage.rs +++ b/graphics/src/damage.rs @@ -45,15 +45,12 @@ pub fn list( /// Groups the given damage regions that are close together inside the given /// bounds. pub fn group(mut damage: Vec, bounds: Rectangle) -> Vec { - use std::cmp::Ordering; - const AREA_THRESHOLD: f32 = 20_000.0; damage.sort_by(|a, b| { a.center() .distance(Point::ORIGIN) - .partial_cmp(&b.center().distance(Point::ORIGIN)) - .unwrap_or(Ordering::Equal) + .total_cmp(&b.center().distance(Point::ORIGIN)) }); let mut output = Vec::new();