Skip to content

Commit 46767b1

Browse files
committed
slice::from_raw_parts: explicitly mention that data must be initialized
1 parent b6c8455 commit 46767b1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/core/src/slice/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -6680,6 +6680,8 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> {
66806680
/// them from other data. You can obtain a pointer that is usable as `data`
66816681
/// for zero-length slices using [`NonNull::dangling()`].
66826682
///
6683+
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
6684+
///
66836685
/// * The memory referenced by the returned slice must not be mutated for the duration
66846686
/// of lifetime `'a`, except inside an `UnsafeCell`.
66856687
///
@@ -6767,6 +6769,8 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
67676769
/// them from other data. You can obtain a pointer that is usable as `data`
67686770
/// for zero-length slices using [`NonNull::dangling()`].
67696771
///
6772+
/// * `data` must point to `len` consecutive properly initialized values of type `T`.
6773+
///
67706774
/// * The memory referenced by the returned slice must not be accessed through any other pointer
67716775
/// (not derived from the return value) for the duration of lifetime `'a`.
67726776
/// Both read and write accesses are forbidden.

0 commit comments

Comments
 (0)