File tree 1 file changed +2
-18
lines changed
1 file changed +2
-18
lines changed Original file line number Diff line number Diff line change @@ -219,29 +219,13 @@ 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 {
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
- // 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) ;
234
- }
235
- }
236
-
237
- // If it's a positive integer.
238
222
#[ cfg( not( feature = "optimize_for_size" ) ) ]
239
223
{
240
- ( * self as $unsigned ) . _fmt( true , f)
224
+ return self . unsigned_abs ( ) . _fmt( * self >= 0 , f) ;
241
225
}
242
226
#[ cfg( feature = "optimize_for_size" ) ]
243
227
{
244
- $gen_name( self . $conv_fn( ) , true , f)
228
+ return $gen_name( self . unsigned_abs ( ) . $conv_fn( ) , * self >= 0 , f) ;
245
229
}
246
230
}
247
231
}
You can’t perform that action at this time.
0 commit comments