Function std::1.0.0 (const: unstable) · source ·
Performs the same functionality as
from_raw_parts, except that a
mutable slice is returned.
Behavior is undefined if any of the following conditions are violated:
datamust be valid for both reads and writes for
len * mem::size_of::<T>()many bytes, 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 aligned even for zero-length slices. One reason for this is that enum layout optimizations may rely on references (including slices of any length) being aligned and non-null to distinguish them from other data. You can obtain a pointer that is usable as
datafor zero-length slices using
datamust point to
lenconsecutive properly initialized values of type
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.
The total size
len * mem::size_of::<T>()of the slice must be no larger than
isize::MAX. See the safety documentation of