Function bitvec::slice::from_raw_parts_mut [−][src]
pub unsafe fn from_raw_parts_mut<'a, O, T>(
data: BitPtr<Mut, O, T>,
len: usize
) -> Result<&'a mut BitSlice<O, T>, BitSpanError<T>> where
O: BitOrder,
T: BitStore,
Performs the same functionality as from_raw_parts, except that a mutable
slice is returned.
Original
API Differences
This takes a BitPtr as its base address, rather than a raw *Bit
pointer, as bitvec does not provide raw pointers to individual bits.
It returns a Result, because the len argument may be invalid to encode
into a &BitSlice reference.
Safety
Behavior is undefined if any of the following conditions are violated:
datamust be valid for boths reads and writes forlenmany bits, and it must be properly aligned. This means in particular:- The entire memory range of this slice must be contained within a single allocated object! Slices can never span across multiple allocated objects.
datamust be non-null, and itsTportion must be aligned. Both of these conditions are checked during safe construction of theBitPtr, andunsafeconstruction of it must not violate them. Doing so will cause incorrect behavior in the crate.
datamust point tolenconsecutive bits within properly initialized memory elementsT.- The memory referenced by the returned slice must not be accessed through
any other pointer (not derived from the return value) for the duration of
lifetime
'a. Both read and write accesses are forbidden. This is true even ifTsupports aliased mutation! An&mutreference requires exclusive access for its lifetime. lencannot exceedBitSlice::MAX_BITS.