pub unsafe fn replace<O, T>(dst: BitPtr<Mut, O, T>, src: bool) -> bool where
O: BitOrder,
T: BitStore, Expand description
Moves src into the pointed dst, returning the previous dst bit.
This function is semantically equivalent to BitRef::replace except that it
operates on raw pointers instead of references. When a proxy reference is
available, prefer BitRef::replace.
Original
Safety
Behavior is undefined if any of the following conditions are violated:
dstmust be valid for both reads and writes.dstmust point to a properly initialized value of typeT.
Examples
use bitvec::prelude::*;
let mut data = 4u8;
let ptr = BitPtr::<_, Lsb0, _>::from_mut(&mut data);
assert!(unsafe {
bitvec::ptr::replace(ptr.add(2), false)
});
assert_eq!(data, 0);