We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
wrapping_neg
1 parent d318878 commit 81d470fCopy full SHA for 81d470f
library/core/src/fmt/num.rs
@@ -219,17 +219,13 @@ macro_rules! impl_Display {
219
#[stable(feature = "rust1", since = "1.0.0")]
220
impl fmt::Display for $signed {
221
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
222
- let is_nonnegative = *self >= 0;
223
-
224
- if !is_nonnegative {
+ if *self < 0 {
225
#[cfg(not(feature = "optimize_for_size"))]
226
{
227
- // convert the negative num to positive by summing 1 to its 2s complement
228
return (!self as $unsigned).wrapping_add(1)._fmt(false, f);
229
}
230
#[cfg(feature = "optimize_for_size")]
231
232
233
return $gen_name((!self.$conv_fn()).wrapping_add(1), false, f);
234
235
0 commit comments