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
37
38
use word::Word;
use bitintr;
/// Set the trailing 0's of `x`.
///
/// If all bits of `x` are set, returns `x`.
///
/// # Intrinsics:
/// - TBM: blsfill.
///
/// # Examples
///
/// ```
/// use bitwise::word::*;
///
/// let n = 0b0110_0000u8;
/// let s = 0b0111_1111u8;
///
/// assert_eq!(n.set_trailing_zeros(), s);
/// assert_eq!(set_trailing_zeros(0b1111_1111u8), 0b1111_1111u8);
/// ```
#[inline]
pub fn set_trailing_zeros<T: Word>(x: T) -> T {
bitintr::x86::tbm::blsfill(x)
}
/// Method version of [`set_trailing_zeros`](fn.set_trailing_zeros.html).
pub trait SetTrailingZeros {
#[inline]
fn set_trailing_zeros(self) -> Self;
}
impl<T: Word> SetTrailingZeros for T {
#[inline]
fn set_trailing_zeros(self) -> Self {
set_trailing_zeros(self)
}
}