Skip to content

Commit ad1ca2c

Browse files
committed
Fix clippy::manual_strip
1 parent fef7db2 commit ad1ca2c

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/lib.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
// Ratio ops often use other "suspicious" ops
2020
#![allow(clippy::suspicious_arithmetic_impl)]
2121
#![allow(clippy::suspicious_op_assign_impl)]
22-
// These use stdlib features higher than the MSRV
23-
#![allow(clippy::manual_strip)] // 1.45
22+
// This uses stdlib features higher than the MSRV
2423
#![allow(clippy::manual_range_contains)] // 1.35
2524

2625
#[cfg(feature = "std")]
@@ -1068,15 +1067,11 @@ macro_rules! impl_formatting {
10681067
format!(concat!($fmt_str, "/", $fmt_str), self.numer, self.denom)
10691068
}
10701069
};
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)
1070+
if let Some(pre_pad) = pre_pad.strip_prefix("-") {
1071+
f.pad_integral(false, $prefix, pre_pad)
1072+
} else {
1073+
f.pad_integral(true, $prefix, &pre_pad)
1074+
}
10801075
}
10811076
#[cfg(not(feature = "std"))]
10821077
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {

0 commit comments

Comments
 (0)