diff options
| author | Ralf Jung <post@ralfj.de> | 2020-09-13 14:02:01 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-09-13 14:02:01 +0200 |
| commit | 46767b1665245d8efa138f0a79d6ecdc7bfbdb08 (patch) | |
| tree | 2cfe6dbe42a9593d9de953c2e64408c3b3004118 | |
| parent | b6c84553c4fa47174d2510541a90243000fb44d8 (diff) | |
| download | rust-46767b1665245d8efa138f0a79d6ecdc7bfbdb08.tar.gz rust-46767b1665245d8efa138f0a79d6ecdc7bfbdb08.zip | |
slice::from_raw_parts: explicitly mention that data must be initialized
| -rw-r--r-- | library/core/src/slice/mod.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 4c027b23584..3ff33fab431 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -6680,6 +6680,8 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> { /// them from other data. You can obtain a pointer that is usable as `data` /// for zero-length slices using [`NonNull::dangling()`]. /// +/// * `data` must point to `len` consecutive properly initialized values of type `T`. +/// /// * The memory referenced by the returned slice must not be mutated for the duration /// of lifetime `'a`, except inside an `UnsafeCell`. /// @@ -6767,6 +6769,8 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { /// them from other data. You can obtain a pointer that is usable as `data` /// for zero-length slices using [`NonNull::dangling()`]. /// +/// * `data` must point to `len` consecutive properly initialized values of type `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. |
