@@ -100,8 +100,8 @@ fn unwrap<T>(t: Option<T>) -> T {
100
100
}
101
101
102
102
macro_rules! int_impl_common {
103
- ( $ty: ty, $bits : expr ) => {
104
- const BITS : u32 = $bits ;
103
+ ( $ty: ty) => {
104
+ const BITS : u32 = < Self > :: BITS ;
105
105
106
106
const ZERO : Self = 0 ;
107
107
const ONE : Self = 1 ;
@@ -232,7 +232,7 @@ macro_rules! int_impl_common {
232
232
}
233
233
234
234
macro_rules! int_impl {
235
- ( $ity: ty, $uty: ty, $bits : expr ) => {
235
+ ( $ity: ty, $uty: ty) => {
236
236
impl Int for $uty {
237
237
type OtherSign = $ity;
238
238
type UnsignedInt = $uty;
@@ -253,7 +253,7 @@ macro_rules! int_impl {
253
253
( self . wrapping_sub( other) as $ity) . wrapping_abs( ) as $uty
254
254
}
255
255
256
- int_impl_common!( $uty, $bits ) ;
256
+ int_impl_common!( $uty) ;
257
257
}
258
258
259
259
impl Int for $ity {
@@ -280,17 +280,17 @@ macro_rules! int_impl {
280
280
self . wrapping_sub( other) . wrapping_abs( ) as $uty
281
281
}
282
282
283
- int_impl_common!( $ity, $bits ) ;
283
+ int_impl_common!( $ity) ;
284
284
}
285
285
} ;
286
286
}
287
287
288
- int_impl ! ( isize , usize , usize :: MAX . count_ones ( ) ) ;
289
- int_impl ! ( i8 , u8 , 8 ) ;
290
- int_impl ! ( i16 , u16 , 16 ) ;
291
- int_impl ! ( i32 , u32 , 32 ) ;
292
- int_impl ! ( i64 , u64 , 64 ) ;
293
- int_impl ! ( i128 , u128 , 128 ) ;
288
+ int_impl ! ( isize , usize ) ;
289
+ int_impl ! ( i8 , u8 ) ;
290
+ int_impl ! ( i16 , u16 ) ;
291
+ int_impl ! ( i32 , u32 ) ;
292
+ int_impl ! ( i64 , u64 ) ;
293
+ int_impl ! ( i128 , u128 ) ;
294
294
295
295
/// Trait for integers twice the bit width of another integer. This is implemented for all
296
296
/// primitives except for `u8`, because there is not a smaller primitive.
0 commit comments