pub unsafe fn copy_nonoverlapping<O1, O2, T1, T2>(
    src: BitPtr<Const, O1, T1>,
    dst: BitPtr<Mut, O2, T2>,
    count: usize
) where
    O1: BitOrder,
    O2: BitOrder,
    T1: BitStore,
    T2: BitStore
Expand description

Copies count bits from src to dst. The source and destination must not overlap.

For regions of memory which might overlap, use copy instead.

copy_nonoverlapping is semantically equivalent to C’s memcpy, but with the argument order swapped.

Original

ptr::copy_nonoverlapping

API Differences

The pointers may differ in bit-ordering or storage element parameters.

Safety

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

  • src must be valid for reads of count bits.
  • dst must be valid for writes of count bits.
  • The region of memory beginning at src with a size of count bits must not overlap with the region of memory beginning at dst with the same size.

Examples

use bitvec::prelude::*;

let mut data = 0b1011u8;
let ptr = BitPtr::<_, Msb0, _>::from_mut(&mut data);

unsafe {
  bitvec::ptr::copy_nonoverlapping(
    ptr.add(4).immut(),
    ptr,
    4,
  );
}
assert_eq!(data, 0b1011_1011);