1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use word::{Word, ToWord, UnsignedWord};
#[inline]
pub fn clear_bits_leq<T: Word, U: UnsignedWord>(x: T, bit: U) -> T {
debug_assert!(T::bit_size() > bit.to());
x & !((T::one() << (T::one() + bit.to())) - T::one())
}
pub trait ClearBitsLeq {
#[inline]
fn clear_bits_leq<U: UnsignedWord>(self, n: U) -> Self;
}
impl<T: Word> ClearBitsLeq for T {
#[inline]
fn clear_bits_leq<U: UnsignedWord>(self, n: U) -> Self {
clear_bits_leq(self, n)
}
}