From bc1216e0464c5bf44158b8cb5319ff70446b5a13 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Mon, 3 Oct 2022 00:41:54 +0000 Subject: [PATCH] Document when `slice::from_ptr_range[_mut]` panic --- library/core/src/slice/raw.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/core/src/slice/raw.rs b/library/core/src/slice/raw.rs index f1e8bc79bf4a..50340a92d0d8 100644 --- a/library/core/src/slice/raw.rs +++ b/library/core/src/slice/raw.rs @@ -188,6 +188,10 @@ pub const fn from_mut(s: &mut T) -> &mut [T] { /// /// Note that a range created from [`slice::as_ptr_range`] fulfills these requirements. /// +/// # Panics +/// +/// This function panics if `T` is a Zero-Sized Type (“ZST”). +/// /// # Caveat /// /// The lifetime for the returned slice is inferred from its usage. To @@ -247,6 +251,10 @@ pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] { /// /// Note that a range created from [`slice::as_mut_ptr_range`] fulfills these requirements. /// +/// # Panics +/// +/// This function panics if `T` is a Zero-Sized Type (“ZST”). +/// /// # Examples /// /// ```