Function bitvec::slice::bits_from_raw_parts_mut[][src]

pub unsafe fn bits_from_raw_parts_mut<'a, O, T>(
    addr: *mut T,
    head: u8,
    bits: usize
) -> Option<&'a mut BitSlice<O, T>> where
    O: BitOrder,
    T: 'a + BitStore + BitMemory

Constructs a &mut BitSlice reference from its component data.

This is logically equivalent to slice::from_raw_parts_mut 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 elements T.
  • T: The type of each memory element in the backing storage region.

Parameters

  • addr: The base address of the memory region that the BitSlice covers.
  • head: The index of the first live bit in *addr, at which the BitSlice begins. This is required to be in the range 0 .. T::Mem::BITS.
  • bits: The number of live bits, beginning at head in *addr, that the BitSlice contains. This must be no greater than BitSlice::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:

  • head is not less than T::Mem::BITS
  • bits is greater than BitSlice::<O, T>::MAX_BITS
  • addr is not adequately aligned to T
  • addr is 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 reachable for the lifetime 'a by any path other than references derived from the return value.