Function alcibiades::bitsets::above_lsb [] [src]

pub fn above_lsb(x: Bitboard) -> Bitboard

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

The way to calculate this is: above_lsb = x ^ -x;.

If x is 0 this function returns 0.

Examples:

assert_eq!(above_lsb(0b10100), !0b111);
assert_eq!(above_lsb(0), 0);

      x          ^        -x         =  above_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
. . . . . . . .     . . . . . . . .     . . . . . . . .
. . . . . . . .     . . . . . . . .     . . . . . . . .