Function alcibiades::bitsets::lsb [] [src]

pub fn lsb(x: Bitboard) -> Bitboard

Returns the LSB of a value.

The way to calculate this is: lsb = x & -x;.

If x is 0 this function returns 0.

Examples:

assert_eq!(lsb(0b10100), 0b100);
assert_eq!(lsb(0), 0);
 
       x         &        -x         =      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 . . . . .
. . . . . . . .     . . . . . . . .     . . . . . . . .
. . . . . . . .     . . . . . . . .     . . . . . . . .