@@ -210,7 +210,7 @@ where
210
210
211
211
let operand = D :: from ( operand) ;
212
212
if operand < D :: from_num ( 1 ) {
213
- let inverse = D :: from_num ( 1 ) . checked_div ( operand) . unwrap ( ) ;
213
+ let inverse = D :: from_num ( 1 ) . checked_div ( operand) . ok_or ( ( ) ) ? ;
214
214
return Ok ( -log2_inner :: < D , D > ( inverse) ) ;
215
215
} ;
216
216
return Ok ( log2_inner :: < D , D > ( operand) ) ;
@@ -240,11 +240,11 @@ where
240
240
} ;
241
241
let neg = operand < ZERO ;
242
242
if neg {
243
- operand = - operand;
243
+ operand = operand. checked_neg ( ) . ok_or ( ( ) ) ? ;
244
244
} ;
245
245
246
246
let operand = D :: from ( operand) ;
247
- let mut result = operand + D :: from_num ( 1 ) ;
247
+ let mut result = operand. checked_add ( D :: from_num ( 1 ) ) . ok_or ( ( ) ) ? ;
248
248
let mut term = operand;
249
249
250
250
for i in 2 ..D :: frac_nbits ( ) {
@@ -317,7 +317,7 @@ where
317
317
}
318
318
319
319
/// power with integer exponend
320
- pub fn powi < S , D > ( operand : S , exponent : i32 ) -> Result < D , ( ) >
320
+ pub fn powi < S , D > ( operand : S , exponent : i32 ) -> Result < D , ( ) >
321
321
where
322
322
S : Fixed + PartialOrd < ConstType > ,
323
323
D : Fixed + PartialOrd < ConstType > + From < S > + From < ConstType > ,
0 commit comments