Skip to content

Commit 82dc3aa

Browse files
committed
link from raw slice creation methods to safety requirements
1 parent ab6e478 commit 82dc3aa

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/libcore/ptr/mod.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,15 @@ pub(crate) struct FatPtr<T> {
221221
pub(crate) len: usize,
222222
}
223223

224-
/// Forms a slice from a pointer and a length.
224+
/// Forms a raw slice from a pointer and a length.
225225
///
226226
/// The `len` argument is the number of **elements**, not the number of bytes.
227227
///
228+
/// This function is safe, but actually using the return value is unsafe.
229+
/// See the documentation of [`from_raw_parts`] for slice safety requirements.
230+
///
231+
/// [`from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html
232+
///
228233
/// # Examples
229234
///
230235
/// ```rust
@@ -243,12 +248,16 @@ pub fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
243248
unsafe { Repr { raw: FatPtr { data, len } }.rust }
244249
}
245250

246-
/// Performs the same functionality as [`from_raw_parts`], except that a
247-
/// mutable slice is returned.
251+
/// Performs the same functionality as [`slice_from_raw_parts`], except that a
252+
/// raw mutable slice is returned.
248253
///
249-
/// See the documentation of [`from_raw_parts`] for more details.
254+
/// See the documentation of [`slice_from_raw_parts`] for more details.
250255
///
251-
/// [`from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html
256+
/// This function is safe, but actually using the return value is unsafe.
257+
/// See the documentation of [`from_raw_parts_mut`] for slice safety requirements.
258+
///
259+
/// [`slice_from_raw_parts`]: fn.slice_from_raw_parts.html
260+
/// [`from_raw_parts_mut`]: ../../std/slice/fn.from_raw_parts_mut.html
252261
#[inline]
253262
#[unstable(feature = "slice_from_raw_parts", reason = "recently added", issue = "36925")]
254263
pub fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {

0 commit comments

Comments
 (0)