Skip to content

Commit ab38c6d

Browse files
Improve code by using wrapping_neg
1 parent d318878 commit ab38c6d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

library/core/src/fmt/num.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ macro_rules! impl_Display {
219219
#[stable(feature = "rust1", since = "1.0.0")]
220220
impl fmt::Display for $signed {
221221
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
222-
let is_nonnegative = *self >= 0;
223-
224-
if !is_nonnegative {
222+
if *self < 0 {
225223
#[cfg(not(feature = "optimize_for_size"))]
226224
{
227225
// convert the negative num to positive by summing 1 to its 2s complement

0 commit comments

Comments
 (0)