Expand description
Overwrites a memory location with the given bit.
Because this reads from memory in order to construct the new value, it cannot be
used to set uninitialized memory. The referent T
element must be fully
initialized (such as with core::ptr::write
) before setting bits with this
function.
Original
Safety
Behavior is undefined if any of the following conditions are violated:
dst
must be valid for writesdst
must point to a properly initialized value of typeT
- no other pointer must race
dst
to view or modify the referent location unlessT
is capable of ensuring race safety.
Examples
use bitvec::prelude::*;
let mut data = 0u8;
let ptr = BitPtr::<_, Lsb0, _>::from_mut(&mut data);
unsafe {
bitvec::ptr::write(ptr.add(2), true);
}
assert_eq!(data, 4);