Skip to main content

rotate_left

Function rotate_left 

Source
pub open spec fn rotate_left(x: usize, n: u32) -> usize
Expand description
{
    let r = n % usize::BITS;
    if r == 0 { x } else { (x << r) | (x >> ((usize::BITS - r) as u32)) }
}

The bits of x shifted left by n % BITS, with the bits shifted out of the top moved into the bottom. A rotation by zero is x; it is a separate case so that no shift is by the full width.