Function bitvec::slice::bits_from_raw_parts [−][src]
pub unsafe fn bits_from_raw_parts<'a, O, T>(
addr: *const T,
head: u8,
bits: usize
) -> Option<&'a BitSlice<O, T>> where
O: BitOrder,
T: 'a + BitStore + BitMemory, Expand description
Constructs a &BitSlice reference from its component data.
This is logically equivalent to slice::from_raw_parts for [T].
Lifetimes
'a: The lifetime of the returned bitslice handle. This must be no longer than the duration of the referent region, as it is illegal for references to dangle.
Type Parameters
O: The ordering of bits within elementsT.T: The type of each memory element in the backing storage region.
Parameters
addr: The base address of the memory region that theBitSlicecovers.head: The index of the first live bit in*addr, at which theBitSlicebegins. This is required to be in the range0 .. T::Mem::BITS.bits: The number of live bits, beginning atheadin*addr, that theBitSlicecontains. This must be no greater thanBitSlice::MAX_BITS.
Returns
If the input parameters are valid, this returns Some shared reference to a
BitSlice. The failure conditions causing this to return None are:
headis not less thanT::Mem::BITSbitsis greater thanBitSlice::<O, T>::MAX_BITSaddris not adequately aligned toTaddris so high in the memory space that the region wraps to the base of the memory space
Safety
The memory region described by the returned BitSlice must be validly allocated
within the caller’s memory management system. It must also not be modified for
the duration of the lifetime 'a, unless the T type parameter permits safe
shared mutation.