From 6e441f64b9f3d7e5401690a00c5ae33455859327 Mon Sep 17 00:00:00 2001 From: Mike Maley Date: Fri, 13 Feb 2026 11:18:19 -0500 Subject: [PATCH] Simplify to_integer The current code for `to_integer` calls `trunc` which calculates the integer then wraps it in a `Ratio` then `to_integer` unwraps the `numer` that `trunc` returned. This commit skips the extra steps. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b1cf2a4..3adc4d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -120,7 +120,7 @@ impl Ratio { /// Converts to an integer, rounding towards zero. #[inline] pub fn to_integer(&self) -> T { - self.trunc().numer + self.numer.clone() / self.denom.clone() } /// Returns true if the rational number is an integer (denominator is 1).