Function set_bits::clear

source ·
pub fn clear(address: usize, start_bit: usize, num_of_bits: usize)
Expand description

Clear num_of_bits bits from the start_bitth bit of address address.

num_of_bits may be more than the number of bits a byte has.

§Examples

Clear 3 bits from the 2nd bit of specified address.

let byte: Box<u32> = Box::new(0);
let ptr = Box::into_raw(byte);

set_bits::set(ptr as usize, 0, 8);
set_bits::clear(ptr as usize, 2, 3);
unsafe {
    assert_eq!(*ptr, 0b11100011);
}

let byte = unsafe { Box::from_raw(ptr) };