@@ -546,6 +546,7 @@ mod imp {
546
546
impl_Exp ! ( i8 , u8 , i16 , u16 , i32 , u32 , isize , usize as u32 via to_u32 named exp_u32) ;
547
547
impl_Exp ! ( i64 , u64 as u64 via to_u64 named exp_u64) ;
548
548
}
549
+ #[ cfg( not( no_iu128_fmt) ) ]
549
550
impl_Exp ! ( i128 , u128 as u128 via to_u128 named exp_u128) ;
550
551
551
552
/// Helper function for writing a u64 into `buf` going from last to first, with `curr`.
@@ -638,21 +639,29 @@ fn parse_u64_into<const N: usize>(mut n: u64, buf: &mut [MaybeUninit<u8>; N], cu
638
639
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
639
640
impl fmt:: Display for u128 {
640
641
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
641
- fmt_u128 ( * self , true , f)
642
+ if cfg ! ( no_iu128_fmt) {
643
+ panic ! ( "u128 formatting support is turned off" )
644
+ } else {
645
+ fmt_u128 ( * self , true , f)
646
+ }
642
647
}
643
648
}
644
649
645
650
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
646
651
impl fmt:: Display for i128 {
647
652
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
648
- let is_nonnegative = * self >= 0 ;
649
- let n = if is_nonnegative {
650
- self . to_u128 ( )
653
+ if cfg ! ( no_iu128_fmt) {
654
+ panic ! ( "u128 formatting support is turned off" )
651
655
} else {
652
- // convert the negative num to positive by summing 1 to its 2s complement
653
- ( !self . to_u128 ( ) ) . wrapping_add ( 1 )
654
- } ;
655
- fmt_u128 ( n, is_nonnegative, f)
656
+ let is_nonnegative = * self >= 0 ;
657
+ let n = if is_nonnegative {
658
+ self . to_u128 ( )
659
+ } else {
660
+ // convert the negative num to positive by summing 1 to its 2s complement
661
+ ( !self . to_u128 ( ) ) . wrapping_add ( 1 )
662
+ } ;
663
+ fmt_u128 ( n, is_nonnegative, f)
664
+ }
656
665
}
657
666
}
658
667
0 commit comments