Function bitvec::ptr::bitslice_from_raw_parts
source · [−]pub fn bitslice_from_raw_parts<O, T>(
data: BitPtr<Const, O, T>,
len: usize
) -> *const BitSlice<O, T> where
O: BitOrder,
T: BitStore,
Expand description
Forms a raw bit-slice from a bit-pointer and a length.
The len
argument is the number of bits, not the number of elements.
This function is safe, but actually using the return value is unsafe. See the
documentation of slice::from_raw_parts
for bit-slice safety requirements.
Original
Examples
use bitvec::ptr;
use bitvec::order::Lsb0;
let x = [5u8, 10, 15];
let bitptr = ptr::BitPtr::<_, Lsb0, _>::from_ref(&x[0]);
let bitslice = ptr::bitslice_from_raw_parts(bitptr, 24);
assert_eq!(unsafe { &*bitslice }[2], true);