diff options
| author | Ralf Jung <post@ralfj.de> | 2019-11-05 09:32:47 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-11-05 09:32:47 +0100 |
| commit | 82dc3aa5fb6642fe0450305015ee68e0c2d1d492 (patch) | |
| tree | 4f3ba3064e27e1ba740b14b7aadc251039498fce /src/libcore/ptr | |
| parent | ab6e47851b51a413db5d721f25d714653e7549fd (diff) | |
link from raw slice creation methods to safety requirements
Diffstat (limited to 'src/libcore/ptr')
| -rw-r--r-- | src/libcore/ptr/mod.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index 1355ce1aa43..649244a4683 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -221,10 +221,15 @@ pub(crate) struct FatPtr<T> { pub(crate) len: usize, } -/// Forms a slice from a pointer and a length. +/// Forms a raw slice from a pointer and a length. /// /// The `len` argument is the number of **elements**, not the number of bytes. /// +/// This function is safe, but actually using the return value is unsafe. +/// See the documentation of [`from_raw_parts`] for slice safety requirements. +/// +/// [`from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html +/// /// # Examples /// /// ```rust @@ -243,12 +248,16 @@ pub fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] { unsafe { Repr { raw: FatPtr { data, len } }.rust } } -/// Performs the same functionality as [`from_raw_parts`], except that a -/// mutable slice is returned. +/// Performs the same functionality as [`slice_from_raw_parts`], except that a +/// raw mutable slice is returned. /// -/// See the documentation of [`from_raw_parts`] for more details. +/// See the documentation of [`slice_from_raw_parts`] for more details. /// -/// [`from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html +/// This function is safe, but actually using the return value is unsafe. +/// See the documentation of [`from_raw_parts_mut`] for slice safety requirements. +/// +/// [`slice_from_raw_parts`]: fn.slice_from_raw_parts.html +/// [`from_raw_parts_mut`]: ../../std/slice/fn.from_raw_parts_mut.html #[inline] #[unstable(feature = "slice_from_raw_parts", reason = "recently added", issue = "36925")] pub fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] { |
