|
19 | 19 | // Ratio ops often use other "suspicious" ops
|
20 | 20 | #![allow(clippy::suspicious_arithmetic_impl)]
|
21 | 21 | #![allow(clippy::suspicious_op_assign_impl)]
|
22 |
| -// These use stdlib features higher than the MSRV |
23 |
| -#![allow(clippy::manual_strip)] // 1.45 |
24 |
| -#![allow(clippy::manual_range_contains)] // 1.35 |
25 | 22 |
|
26 | 23 | #[cfg(feature = "std")]
|
27 | 24 | #[macro_use]
|
@@ -1068,15 +1065,11 @@ macro_rules! impl_formatting {
|
1068 | 1065 | format!(concat!($fmt_str, "/", $fmt_str), self.numer, self.denom)
|
1069 | 1066 | }
|
1070 | 1067 | };
|
1071 |
| - // TODO: replace with strip_prefix, when stabilized |
1072 |
| - let (pre_pad, non_negative) = { |
1073 |
| - if pre_pad.starts_with("-") { |
1074 |
| - (&pre_pad[1..], false) |
1075 |
| - } else { |
1076 |
| - (&pre_pad[..], true) |
1077 |
| - } |
1078 |
| - }; |
1079 |
| - f.pad_integral(non_negative, $prefix, pre_pad) |
| 1068 | + if let Some(pre_pad) = pre_pad.strip_prefix("-") { |
| 1069 | + f.pad_integral(false, $prefix, pre_pad) |
| 1070 | + } else { |
| 1071 | + f.pad_integral(true, $prefix, &pre_pad) |
| 1072 | + } |
1080 | 1073 | }
|
1081 | 1074 | #[cfg(not(feature = "std"))]
|
1082 | 1075 | fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
@@ -1585,7 +1578,8 @@ fn ratio_to_f64<T: Bits + Clone + Integer + Signed + ShlAssign<usize> + ToPrimit
|
1585 | 1578 | // FPU do the job is faster and easier. In any other case, converting to f64s may lead
|
1586 | 1579 | // to an inexact result: https://stackoverflow.com/questions/56641441/.
|
1587 | 1580 | if let (Some(n), Some(d)) = (numer.to_i64(), denom.to_i64()) {
|
1588 |
| - if MIN_EXACT_INT <= n && n <= MAX_EXACT_INT && MIN_EXACT_INT <= d && d <= MAX_EXACT_INT { |
| 1581 | + let exact = MIN_EXACT_INT..=MAX_EXACT_INT; |
| 1582 | + if exact.contains(&n) && exact.contains(&d) { |
1589 | 1583 | return n.to_f64().unwrap() / d.to_f64().unwrap();
|
1590 | 1584 | }
|
1591 | 1585 | }
|
|
0 commit comments