RS.CLIPPY.VERBOSE_BIT_MASK

Expressions where a bit mask is less readable than the corresponding method call

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: verbose_bit_mask. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for bit masks that can be replaced by a call to trailing_zeros

Why is this bad?

x.trailing_zeros() >= 4 is much clearer than x & 15 == 0

Example

if x & 0b1111 == 0 { }

Use instead:

if x.trailing_zeros() >= 4 { }

Configuration

  • verbose-bit-mask-threshold: The maximum allowed size of a bit mask before suggesting to use 'trailing_zeros'

    (default: 1)