Skip to content

Commit ec9491d

Browse files
committed
add numer_mut() denom_mut()
1 parent 4d55ad2 commit ec9491d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ impl<T> Ratio<T> {
9898
pub const fn denom(&self) -> &T {
9999
&self.denom
100100
}
101+
102+
/// Gets an mutable reference to the numerator.
103+
#[inline]
104+
pub const fn numer_mut(&mut self) -> &mut T {
105+
&mut self.numer
106+
}
107+
108+
/// Gets an mutable reference to the denominator.
109+
///
110+
/// **There are several methods that will panic if used on a `Ratio` with
111+
/// `denom == 0`.**
112+
#[inline]
113+
pub const fn denom_mut(&mut self) -> &mut T {
114+
&mut self.denom
115+
}
101116
}
102117

103118
impl<T: Clone + Integer> Ratio<T> {

0 commit comments

Comments
 (0)