File tree 1 file changed +3
-7
lines changed
1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -219,18 +219,14 @@ macro_rules! impl_Display {
219
219
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
220
220
impl fmt:: Display for $signed {
221
221
fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
222
- let is_nonnegative = * self >= 0 ;
223
-
224
- if !is_nonnegative {
222
+ if * self < 0 {
225
223
#[ cfg( not( feature = "optimize_for_size" ) ) ]
226
224
{
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) ;
225
+ return ( self . wrapping_neg( ) as $unsigned) . _fmt( false , f) ;
229
226
}
230
227
#[ cfg( feature = "optimize_for_size" ) ]
231
228
{
232
- // convert the negative num to positive by summing 1 to its 2s complement
233
- return $gen_name( ( !self . $conv_fn( ) ) . wrapping_add( 1 ) , false , f) ;
229
+ return $gen_name( self . wrapping_neg( ) . $conv_fn( ) , false , f) ;
234
230
}
235
231
}
236
232
You can’t perform that action at this time.
0 commit comments