File tree Expand file tree Collapse file tree 1 file changed +2
-18
lines changed Expand file tree Collapse file tree 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 {
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 {
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.
238222 #[ cfg( not( feature = "optimize_for_size" ) ) ]
239223 {
240- ( * self as $unsigned ) . _fmt( true , f)
224+ return self . unsigned_abs ( ) . _fmt( * self >= 0 , f) ;
241225 }
242226 #[ cfg( feature = "optimize_for_size" ) ]
243227 {
244- $gen_name( self . $conv_fn( ) , true , f)
228+ return $gen_name( self . unsigned_abs ( ) . $conv_fn( ) , * self >= 0 , f) ;
245229 }
246230 }
247231 }
You can’t perform that action at this time.
0 commit comments