@@ -69,12 +69,10 @@ pub type BigRational = Ratio<BigInt>;
6969
7070/// These method are `const` for Rust 1.31 and later.
7171impl < T > Ratio < T > {
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- */
72+ /// Creates a `Ratio` without checking for `denom == 0` or reducing.
73+ ///
74+ /// **There are several methods that will panic if used on a `Ratio` with
75+ /// `denom == 0`.**
7876 #[ inline]
7977 pub const fn new_raw ( numer : T , denom : T ) -> Ratio < T > {
8078 Ratio { numer, denom }
@@ -94,11 +92,9 @@ impl<T> Ratio<T> {
9492}
9593
9694impl < T : Clone + Integer > Ratio < T > {
97- /**
98- Creates a new `Ratio`.
99-
100- **Panics if `denom` is zero.**
101- */
95+ /// Creates a new `Ratio`.
96+ ///
97+ /// **Panics if `denom` is zero.**
10298 #[ inline]
10399 pub fn new ( numer : T , denom : T ) -> Ratio < T > {
104100 let mut ret = Ratio :: new_raw ( numer, denom) ;
@@ -124,11 +120,9 @@ impl<T: Clone + Integer> Ratio<T> {
124120 self . denom . is_one ( )
125121 }
126122
127- /**
128- Puts self into lowest terms, with `denom` > 0.
129-
130- **Panics if `denom` is zero.**
131- */
123+ /// Puts self into lowest terms, with `denom` > 0.
124+ ///
125+ /// **Panics if `denom` is zero.**
132126 fn reduce ( & mut self ) {
133127 if self . denom . is_zero ( ) {
134128 panic ! ( "denominator == 0" ) ;
@@ -159,25 +153,21 @@ impl<T: Clone + Integer> Ratio<T> {
159153 }
160154 }
161155
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- */
156+ /// Returns a reduced copy of self.
157+ ///
158+ /// In general, it is not necessary to use this method, as the only
159+ /// method of procuring a non-reduced fraction is through `new_raw`.
160+ ///
161+ /// **Panics if `denom` is zero.**
170162 pub fn reduced ( & self ) -> Ratio < T > {
171163 let mut ret = self . clone ( ) ;
172164 ret. reduce ( ) ;
173165 ret
174166 }
175167
176- /**
177- Returns the reciprocal.
178-
179- **Panics if the `Ratio` is zero.**
180- */
168+ /// Returns the reciprocal.
169+ ///
170+ /// **Panics if the `Ratio` is zero.**
181171 #[ inline]
182172 pub fn recip ( & self ) -> Ratio < T > {
183173 self . clone ( ) . into_recip ( )
@@ -487,7 +477,7 @@ mod opassign {
487477 self . numer *= other. denom / gcd_bd. clone ( ) ;
488478 self . denom /= gcd_bd;
489479 self . denom *= other. numer / gcd_ac;
490- self . reduce ( ) ; //TODO: remove this line. see #8.
480+ self . reduce ( ) ; // TODO: remove this line. see #8.
491481 }
492482 }
493483
@@ -500,7 +490,7 @@ mod opassign {
500490 self . numer *= other. numer / gcd_bc. clone ( ) ;
501491 self . denom /= gcd_bc;
502492 self . denom *= other. denom / gcd_ad;
503- self . reduce ( ) ; //TODO: remove this line. see #8.
493+ self . reduce ( ) ; // TODO: remove this line. see #8.
504494 }
505495 }
506496
@@ -547,7 +537,7 @@ mod opassign {
547537 let gcd = self . numer . gcd ( & other) ;
548538 self . numer /= gcd. clone ( ) ;
549539 self . denom *= other / gcd;
550- self . reduce ( ) ; //TODO: remove this line. see #8.
540+ self . reduce ( ) ; // TODO: remove this line. see #8.
551541 }
552542 }
553543
@@ -556,7 +546,7 @@ mod opassign {
556546 let gcd = self . denom . gcd ( & other) ;
557547 self . denom /= gcd. clone ( ) ;
558548 self . numer *= other / gcd;
559- self . reduce ( ) ; //TODO: remove this line. see #8.
549+ self . reduce ( ) ; // TODO: remove this line. see #8.
560550 }
561551 }
562552
@@ -1035,7 +1025,7 @@ macro_rules! impl_formatting {
10351025 format!( concat!( $fmt_str, "/" , $fmt_str) , self . numer, self . denom)
10361026 }
10371027 } ;
1038- //TODO: replace with strip_prefix, when stabalized
1028+ // TODO: replace with strip_prefix, when stabalized
10391029 let ( pre_pad, non_negative) = {
10401030 if pre_pad. starts_with( "-" ) {
10411031 ( & pre_pad[ 1 ..] , false )
@@ -1965,7 +1955,7 @@ mod test {
19651955 assert_fmt_eq ! ( format_args!( "{:-b}" , _1_2) , "1/10" ) ;
19661956 assert_fmt_eq ! ( format_args!( "{:b}" , _0) , "0" ) ;
19671957 assert_fmt_eq ! ( format_args!( "{:#b}" , _1_2) , "0b1/0b10" ) ;
1968- //no std does not support padding
1958+ // no std does not support padding
19691959 #[ cfg( feature = "std" ) ]
19701960 assert_eq ! ( & format!( "{:010b}" , _1_2) , "0000001/10" ) ;
19711961 #[ cfg( feature = "std" ) ]
@@ -2397,7 +2387,7 @@ mod test {
23972387 T : Integer + Bounded + Clone + Debug + NumAssign ,
23982388 {
23992389 let two = T :: one ( ) + T :: one ( ) ;
2400- //value near to maximum, but divisible by two
2390+ // value near to maximum, but divisible by two
24012391 let max_div2 = T :: max_value ( ) / two. clone ( ) * two. clone ( ) ;
24022392 let _1_max: Ratio < T > = Ratio :: new ( T :: one ( ) , max_div2) ;
24032393 let _1_two: Ratio < T > = Ratio :: new ( T :: one ( ) , two) ;
0 commit comments