From 55429b3eade5077d1bfb07a46e3f5da3d9d0b302 Mon Sep 17 00:00:00 2001 From: TimTheBig <132001783+TimTheBig@users.noreply.github.com> Date: Tue, 26 May 2026 11:36:39 -0400 Subject: [PATCH] Take reference for `Real::min/max` --- src/real/arithmetic.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/real/arithmetic.rs b/src/real/arithmetic.rs index 80bb018..d8e8377 100644 --- a/src/real/arithmetic.rs +++ b/src/real/arithmetic.rs @@ -1161,8 +1161,8 @@ impl Real { /// If refinement cannot decide the order at the standard partial-order /// precision, this keeps `self`, matching the conservative behavior of /// [`PartialOrd`] callers that treat incomparability as no improvement. - pub fn min(self, other: Real) -> Real { - match self.partial_cmp(&other) { + pub fn min<'r>(&'r self, other: &'r Real) -> &'r Real { + match self.partial_cmp(other) { Some(Ordering::Greater) => other, _ => self, } @@ -1173,8 +1173,8 @@ impl Real { /// If refinement cannot decide the order at the standard partial-order /// precision, this keeps `self`, matching the conservative behavior of /// [`PartialOrd`] callers that treat incomparability as no improvement. - pub fn max(self, other: Real) -> Real { - match self.partial_cmp(&other) { + pub fn max<'r>(&'r self, other: &'r Real) -> &'r Real { + match self.partial_cmp(other) { Some(Ordering::Less) => other, _ => self, }