Function alcibiades::bitsets::reset_lsb [] [src]

pub fn reset_lsb(x: &mut Bitboard)

Resets the LSB of a value to zero.

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

If *x is 0 this function does nothing.

Examples:

let mut x = 0b100100;
reset_lsb(&mut x);
assert_eq!(x, 0b100000);
reset_lsb(&mut x);
assert_eq!(x, 0);
reset_lsb(&mut x);
assert_eq!(x, 0);

      x          &      (x - 1)      =  x_with_reset_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     . . . . . . . .