cast::revm::interpreter::primitives::bitvec::ptr

Function replace

pub unsafe fn replace<T, O>(dst: BitPtr<Mut, T, O>, src: bool) -> bool
where T: BitStore, O: BitOrder,
Available on non-tarpaulin_include only.
Expand description

§Single-Bit Replacement

This writes a new value into a location, and returns the bit-value previously stored there. It is semantically and behaviorally equivalent to BitRef::replace, except that it works on bit-pointer structures rather than proxy references. Prefer to use a proxy reference or BitSlice::replace instead.

§Original

ptr::replace

§Safety

This has the same safety requirements as ptr::read and ptr::write, as it is required to use them in its implementation.

§Examples

use bitvec::prelude::*;
use bitvec::ptr as bv_ptr;

let mut data = 4u8;
let ptr = BitPtr::<_, _, Lsb0>::from_mut(&mut data);
assert!(unsafe {
  bv_ptr::replace(ptr.add(2), false)
});
assert_eq!(data, 0);