@@ -83,6 +83,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
83
83
/// Reverses the order of bits in the integer. The least significant bit
84
84
/// becomes the most significant bit, second least-significant bit becomes
85
85
/// second most-significant bit, etc.
86
+ #[ inline]
86
87
#[ must_use]
87
88
pub fn reverse_bits ( mut self ) -> Self {
88
89
self . limbs . reverse ( ) ;
@@ -97,6 +98,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
97
98
98
99
/// Returns the number of leading zeros in the binary representation of
99
100
/// `self`.
101
+ #[ inline]
100
102
#[ must_use]
101
103
pub fn leading_zeros ( & self ) -> usize {
102
104
self . as_limbs ( )
@@ -113,13 +115,15 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
113
115
114
116
/// Returns the number of leading ones in the binary representation of
115
117
/// `self`.
118
+ #[ inline]
116
119
#[ must_use]
117
120
pub fn leading_ones ( & self ) -> usize {
118
121
( self . not ( ) ) . leading_zeros ( )
119
122
}
120
123
121
124
/// Returns the number of trailing zeros in the binary representation of
122
125
/// `self`.
126
+ #[ inline]
123
127
#[ must_use]
124
128
pub fn trailing_zeros ( & self ) -> usize {
125
129
self . as_limbs ( )
@@ -132,6 +136,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
132
136
133
137
/// Returns the number of trailing ones in the binary representation of
134
138
/// `self`.
139
+ #[ inline]
135
140
#[ must_use]
136
141
pub fn trailing_ones ( & self ) -> usize {
137
142
self . as_limbs ( )
@@ -143,6 +148,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
143
148
}
144
149
145
150
/// Returns the number of ones in the binary representation of `self`.
151
+ #[ inline]
146
152
#[ must_use]
147
153
pub fn count_ones ( & self ) -> usize {
148
154
self . as_limbs ( )
@@ -183,6 +189,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
183
189
///
184
190
/// If `self` is $<≥> 2^{63}$, then `exponent` will be zero and `bits` will
185
191
/// have leading zeros.
192
+ #[ inline]
186
193
#[ must_use]
187
194
pub fn most_significant_bits ( & self ) -> ( u64 , usize ) {
188
195
let first_set_limb = self
@@ -245,6 +252,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
245
252
///
246
253
/// Note: This differs from [`u64::overflowing_shl`] which returns `true` if
247
254
/// the shift is larger than `BITS` (which is IMHO not very useful).
255
+ #[ inline]
248
256
#[ must_use]
249
257
pub fn overflowing_shl ( mut self , rhs : usize ) -> ( Self , bool ) {
250
258
let ( limbs, bits) = ( rhs / 64 , rhs % 64 ) ;
@@ -341,6 +349,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
341
349
///
342
350
/// Note: This differs from [`u64::overflowing_shr`] which returns `true` if
343
351
/// the shift is larger than `BITS` (which is IMHO not very useful).
352
+ #[ inline]
344
353
#[ must_use]
345
354
pub fn overflowing_shr ( mut self , rhs : usize ) -> ( Self , bool ) {
346
355
let ( limbs, bits) = ( rhs / 64 , rhs % 64 ) ;
@@ -399,6 +408,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
399
408
}
400
409
401
410
/// Arithmetic shift right by `rhs` bits.
411
+ #[ inline]
402
412
#[ must_use]
403
413
pub fn arithmetic_shr ( self , rhs : usize ) -> Self {
404
414
if BITS == 0 {
@@ -414,6 +424,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
414
424
415
425
/// Shifts the bits to the left by a specified amount, `rhs`, wrapping the
416
426
/// truncated bits to the end of the resulting integer.
427
+ #[ inline]
417
428
#[ must_use]
418
429
#[ allow( clippy:: missing_const_for_fn) ] // False positive
419
430
pub fn rotate_left ( self , rhs : usize ) -> Self {
@@ -424,6 +435,8 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
424
435
self << rhs | self >> ( BITS - rhs)
425
436
}
426
437
438
+ /// Shifts the bits to the right by a specified amount, `rhs`, wrapping the
439
+ /// truncated bits to the beginning of the resulting integer.
427
440
#[ inline( always) ]
428
441
#[ must_use]
429
442
pub fn rotate_right ( self , rhs : usize ) -> Self {
@@ -438,6 +451,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
438
451
impl < const BITS : usize , const LIMBS : usize > Not for Uint < BITS , LIMBS > {
439
452
type Output = Self ;
440
453
454
+ #[ inline]
441
455
fn not ( mut self ) -> Self :: Output {
442
456
if BITS == 0 {
443
457
return Self :: ZERO ;
@@ -453,6 +467,7 @@ impl<const BITS: usize, const LIMBS: usize> Not for Uint<BITS, LIMBS> {
453
467
impl < const BITS : usize , const LIMBS : usize > Not for & Uint < BITS , LIMBS > {
454
468
type Output = Uint < BITS , LIMBS > ;
455
469
470
+ #[ inline]
456
471
fn not ( self ) -> Self :: Output {
457
472
( * self ) . not ( )
458
473
}
@@ -471,6 +486,7 @@ macro_rules! impl_bit_op {
471
486
impl <const BITS : usize , const LIMBS : usize > $trait_assign<& Uint <BITS , LIMBS >>
472
487
for Uint <BITS , LIMBS >
473
488
{
489
+ #[ inline]
474
490
fn $fn_assign( & mut self , rhs: & Uint <BITS , LIMBS >) {
475
491
for ( limb, & rhs) in self . limbs. iter_mut( ) . zip( rhs. as_limbs( ) ) {
476
492
u64 :: $fn_assign( limb, rhs) ;
0 commit comments