Function alcibiades::bitsets::below_lsb [] [src]

pub fn below_lsb(x: Bitboard) -> Bitboard

Returns a mask with all bits below the LSB set to 1.

The way to calculate this is: below_lsb = !x & (x - 1);.

If x is 0 this function returns 0xffffffffffffffff.

Examples:

assert_eq!(below_lsb(0b10100), 0b11);
assert_eq!(below_lsb(0), !0);
     !x          &      (x - 1)      =  below_lsb(x)
1 1 1 1 1 1 1 1     . . . . . . . .     . . . . . . . .
1 1 . 1 . 1 1 1     . . 1 . 1 . . .     . . . . . . . .
1 . 1 1 1 . 1 1     . 1 . . . 1 . .     . . . . . . . .
1 1 1 1 1 1 1 1     . . . . . . . .     . . . . . . . .
1 . 1 1 1 . 1 1  &  . 1 . . . 1 . .  =  . . . . . . . .
1 1 . 1 . 1 1 1     1 1 . . 1 . . .     1 1 . . . . . .
1 1 1 1 1 1 1 1     1 1 1 1 1 1 1 1     1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1     1 1 1 1 1 1 1 1     1 1 1 1 1 1 1 1