@@ -2331,16 +2331,14 @@ impl ToPrimitive for BigInt {
2331
2331
2332
2332
#[ inline]
2333
2333
fn to_f32 ( & self ) -> Option < f32 > {
2334
- self . data
2335
- . to_f32 ( )
2336
- . map ( |n| if self . sign == Minus { -n } else { n } )
2334
+ let n = self . data . to_f32 ( ) ?;
2335
+ Some ( if self . sign == Minus { -n } else { n } )
2337
2336
}
2338
2337
2339
2338
#[ inline]
2340
2339
fn to_f64 ( & self ) -> Option < f64 > {
2341
- self . data
2342
- . to_f64 ( )
2343
- . map ( |n| if self . sign == Minus { -n } else { n } )
2340
+ let n = self . data . to_f64 ( ) ?;
2341
+ Some ( if self . sign == Minus { -n } else { n } )
2344
2342
}
2345
2343
}
2346
2344
@@ -2370,7 +2368,8 @@ impl FromPrimitive for BigInt {
2370
2368
if n >= 0.0 {
2371
2369
BigUint :: from_f64 ( n) . map ( BigInt :: from)
2372
2370
} else {
2373
- BigUint :: from_f64 ( -n) . map ( |x| -BigInt :: from ( x) )
2371
+ let x = BigUint :: from_f64 ( -n) ?;
2372
+ Some ( -BigInt :: from ( x) )
2374
2373
}
2375
2374
}
2376
2375
}
@@ -2727,9 +2726,8 @@ impl BigInt {
2727
2726
/// ```
2728
2727
#[ inline]
2729
2728
pub fn parse_bytes ( buf : & [ u8 ] , radix : u32 ) -> Option < BigInt > {
2730
- str:: from_utf8 ( buf)
2731
- . ok ( )
2732
- . and_then ( |s| BigInt :: from_str_radix ( s, radix) . ok ( ) )
2729
+ let s = str:: from_utf8 ( buf) . ok ( ) ?;
2730
+ BigInt :: from_str_radix ( s, radix) . ok ( )
2733
2731
}
2734
2732
2735
2733
/// Creates and initializes a `BigInt`. Each u8 of the input slice is
@@ -2749,7 +2747,8 @@ impl BigInt {
2749
2747
/// assert_eq!(a.to_radix_be(190), (Sign:: Minus, inbase190));
2750
2748
/// ```
2751
2749
pub fn from_radix_be ( sign : Sign , buf : & [ u8 ] , radix : u32 ) -> Option < BigInt > {
2752
- BigUint :: from_radix_be ( buf, radix) . map ( |u| BigInt :: from_biguint ( sign, u) )
2750
+ let u = BigUint :: from_radix_be ( buf, radix) ?;
2751
+ Some ( BigInt :: from_biguint ( sign, u) )
2753
2752
}
2754
2753
2755
2754
/// Creates and initializes a `BigInt`. Each u8 of the input slice is
@@ -2769,7 +2768,8 @@ impl BigInt {
2769
2768
/// assert_eq!(a.to_radix_be(190), (Sign::Minus, inbase190));
2770
2769
/// ```
2771
2770
pub fn from_radix_le ( sign : Sign , buf : & [ u8 ] , radix : u32 ) -> Option < BigInt > {
2772
- BigUint :: from_radix_le ( buf, radix) . map ( |u| BigInt :: from_biguint ( sign, u) )
2771
+ let u = BigUint :: from_radix_le ( buf, radix) ?;
2772
+ Some ( BigInt :: from_biguint ( sign, u) )
2773
2773
}
2774
2774
2775
2775
/// Returns the sign and the byte representation of the `BigInt` in big-endian byte order.
0 commit comments