@@ -69,7 +69,12 @@ pub type BigRational = Ratio<BigInt>;
6969
7070/// These method are `const` for Rust 1.31 and later.
7171impl < T > Ratio < T > {
72- /// Creates a `Ratio` without checking for `denom == 0` or reducing.
72+ /**
73+ Creates a `Ratio` without checking for `denom == 0` or reducing.
74+
75+ **There are several methods that will panic if used on a `Ratio` with
76+ `denom == 0`.**
77+ */
7378 #[ inline]
7479 pub const fn new_raw ( numer : T , denom : T ) -> Ratio < T > {
7580 Ratio { numer, denom }
@@ -89,7 +94,11 @@ impl<T> Ratio<T> {
8994}
9095
9196impl < T : Clone + Integer > Ratio < T > {
92- /// Creates a new `Ratio`. Fails if `denom` is zero.
97+ /**
98+ Creates a new `Ratio`.
99+
100+ **Panics if `denom` is zero.**
101+ */
93102 #[ inline]
94103 pub fn new ( numer : T , denom : T ) -> Ratio < T > {
95104 let mut ret = Ratio :: new_raw ( numer, denom) ;
@@ -115,7 +124,11 @@ impl<T: Clone + Integer> Ratio<T> {
115124 self . denom . is_one ( )
116125 }
117126
118- /// Puts self into lowest terms, with denom > 0.
127+ /**
128+ Puts self into lowest terms, with `denom` > 0.
129+
130+ **Panics if `denom` is zero.**
131+ */
119132 fn reduce ( & mut self ) {
120133 if self . denom . is_zero ( ) {
121134 panic ! ( "denominator == 0" ) ;
@@ -146,19 +159,25 @@ impl<T: Clone + Integer> Ratio<T> {
146159 }
147160 }
148161
149- /// Returns a reduced copy of self.
150- ///
151- /// In general, it is not necessary to use this method, as the only
152- /// method of procuring a non-reduced fraction is through `new_raw`.
162+ /**
163+ Returns a reduced copy of self.
164+
165+ In general, it is not necessary to use this method, as the only
166+ method of procuring a non-reduced fraction is through `new_raw`.
167+
168+ **Panics if `denom` is zero.**
169+ */
153170 pub fn reduced ( & self ) -> Ratio < T > {
154171 let mut ret = self . clone ( ) ;
155172 ret. reduce ( ) ;
156173 ret
157174 }
158175
159- /// Returns the reciprocal.
160- ///
161- /// Fails if the `Ratio` is zero.
176+ /**
177+ Returns the reciprocal.
178+
179+ **Panics if the `Ratio` is zero.**
180+ */
162181 #[ inline]
163182 pub fn recip ( & self ) -> Ratio < T > {
164183 self . clone ( ) . into_recip ( )
0 commit comments