@@ -69,12 +69,10 @@ pub type BigRational = Ratio<BigInt>;
69
69
70
70
/// These method are `const` for Rust 1.31 and later.
71
71
impl < 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`.**
78
76
#[ inline]
79
77
pub const fn new_raw ( numer : T , denom : T ) -> Ratio < T > {
80
78
Ratio { numer, denom }
@@ -94,11 +92,9 @@ impl<T> Ratio<T> {
94
92
}
95
93
96
94
impl < 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.**
102
98
#[ inline]
103
99
pub fn new ( numer : T , denom : T ) -> Ratio < T > {
104
100
let mut ret = Ratio :: new_raw ( numer, denom) ;
@@ -124,11 +120,9 @@ impl<T: Clone + Integer> Ratio<T> {
124
120
self . denom . is_one ( )
125
121
}
126
122
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.**
132
126
fn reduce ( & mut self ) {
133
127
if self . denom . is_zero ( ) {
134
128
panic ! ( "denominator == 0" ) ;
@@ -159,25 +153,21 @@ impl<T: Clone + Integer> Ratio<T> {
159
153
}
160
154
}
161
155
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.**
170
162
pub fn reduced ( & self ) -> Ratio < T > {
171
163
let mut ret = self . clone ( ) ;
172
164
ret. reduce ( ) ;
173
165
ret
174
166
}
175
167
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.**
181
171
#[ inline]
182
172
pub fn recip ( & self ) -> Ratio < T > {
183
173
self . clone ( ) . into_recip ( )
@@ -487,7 +477,7 @@ mod opassign {
487
477
self . numer *= other. denom / gcd_bd. clone ( ) ;
488
478
self . denom /= gcd_bd;
489
479
self . denom *= other. numer / gcd_ac;
490
- self . reduce ( ) ; //TODO: remove this line. see #8.
480
+ self . reduce ( ) ; // TODO: remove this line. see #8.
491
481
}
492
482
}
493
483
@@ -500,7 +490,7 @@ mod opassign {
500
490
self . numer *= other. numer / gcd_bc. clone ( ) ;
501
491
self . denom /= gcd_bc;
502
492
self . denom *= other. denom / gcd_ad;
503
- self . reduce ( ) ; //TODO: remove this line. see #8.
493
+ self . reduce ( ) ; // TODO: remove this line. see #8.
504
494
}
505
495
}
506
496
@@ -547,7 +537,7 @@ mod opassign {
547
537
let gcd = self . numer . gcd ( & other) ;
548
538
self . numer /= gcd. clone ( ) ;
549
539
self . denom *= other / gcd;
550
- self . reduce ( ) ; //TODO: remove this line. see #8.
540
+ self . reduce ( ) ; // TODO: remove this line. see #8.
551
541
}
552
542
}
553
543
@@ -556,7 +546,7 @@ mod opassign {
556
546
let gcd = self . denom . gcd ( & other) ;
557
547
self . denom /= gcd. clone ( ) ;
558
548
self . numer *= other / gcd;
559
- self . reduce ( ) ; //TODO: remove this line. see #8.
549
+ self . reduce ( ) ; // TODO: remove this line. see #8.
560
550
}
561
551
}
562
552
@@ -1035,7 +1025,7 @@ macro_rules! impl_formatting {
1035
1025
format!( concat!( $fmt_str, "/" , $fmt_str) , self . numer, self . denom)
1036
1026
}
1037
1027
} ;
1038
- //TODO: replace with strip_prefix, when stabalized
1028
+ // TODO: replace with strip_prefix, when stabalized
1039
1029
let ( pre_pad, non_negative) = {
1040
1030
if pre_pad. starts_with( "-" ) {
1041
1031
( & pre_pad[ 1 ..] , false )
@@ -1965,7 +1955,7 @@ mod test {
1965
1955
assert_fmt_eq ! ( format_args!( "{:-b}" , _1_2) , "1/10" ) ;
1966
1956
assert_fmt_eq ! ( format_args!( "{:b}" , _0) , "0" ) ;
1967
1957
assert_fmt_eq ! ( format_args!( "{:#b}" , _1_2) , "0b1/0b10" ) ;
1968
- //no std does not support padding
1958
+ // no std does not support padding
1969
1959
#[ cfg( feature = "std" ) ]
1970
1960
assert_eq ! ( & format!( "{:010b}" , _1_2) , "0000001/10" ) ;
1971
1961
#[ cfg( feature = "std" ) ]
@@ -2397,7 +2387,7 @@ mod test {
2397
2387
T : Integer + Bounded + Clone + Debug + NumAssign ,
2398
2388
{
2399
2389
let two = T :: one ( ) + T :: one ( ) ;
2400
- //value near to maximum, but divisible by two
2390
+ // value near to maximum, but divisible by two
2401
2391
let max_div2 = T :: max_value ( ) / two. clone ( ) * two. clone ( ) ;
2402
2392
let _1_max: Ratio < T > = Ratio :: new ( T :: one ( ) , max_div2) ;
2403
2393
let _1_two: Ratio < T > = Ratio :: new ( T :: one ( ) , two) ;
0 commit comments