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
Expand description

Performs the same functionality as from_raw_parts, except that a mutable slice is returned.

Original

slice::from_raw_parts_mut

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:

  • data must be valid for boths reads and writes for len many 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.
    • data must be non-null, and its T portion must be aligned. Both of these conditions are checked during safe construction of the BitPtr, and unsafe construction of it must not violate them. Doing so will cause incorrect behavior in the crate.
  • data must point to len consecutive bits within properly initialized memory elements T.
  • 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 if T supports aliased mutation! An &mut reference requires exclusive access for its lifetime.
  • len cannot exceed BitSlice::MAX_BITS.