Closed
Description
Consider the following:
pub const fn WTERMSIG(s: c::c_int) -> c::c_int {
s & 0x7f
}
pub const fn WIFEXITED(s: c::c_int) -> bool {
s & 0x7f == 0 // <--- try: `s.trailing_zeros() >= 7`
}
The documentation for verbose_bit_mask has the following example:
x.trailing_zeros() > 4
is much clearer thanx & 15 == 0
But this statement is wrong in the general case. Code such as x & 15
is often accompanied by other bit-fiddling to extract certain parts of the integer such as in the example above. Using trailing_zeros
in one place and & 15
in the other makes the code as a whole much less clear.
verbose_bit_mask should be disabled by default.
cc @oli-obk