Function bitvec::ptr::replace

source · []
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

ptr::replace

Safety

Behavior is undefined if any of the following conditions are violated:

  • dst must be valid for both reads and writes.
  • dst must point to a properly initialized value of type T.

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);