From ec9491dc92d5dc2d630cb889d7f7a790b4d6be24 Mon Sep 17 00:00:00 2001 From: James Deng Date: Wed, 1 Oct 2025 00:38:09 -0700 Subject: [PATCH] add numer_mut() denom_mut() --- src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index b1cf2a4..1ad5005 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,6 +98,21 @@ impl Ratio { pub const fn denom(&self) -> &T { &self.denom } + + /// Gets an mutable reference to the numerator. + #[inline] + pub const fn numer_mut(&mut self) -> &mut T { + &mut self.numer + } + + /// Gets an mutable reference to the denominator. + /// + /// **There are several methods that will panic if used on a `Ratio` with + /// `denom == 0`.** + #[inline] + pub const fn denom_mut(&mut self) -> &mut T { + &mut self.denom + } } impl Ratio {