Skip to content

Commit bc1216e

Browse files
committed
Document when slice::from_ptr_range[_mut] panic
1 parent 47b2eee commit bc1216e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/core/src/slice/raw.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
188188
///
189189
/// Note that a range created from [`slice::as_ptr_range`] fulfills these requirements.
190190
///
191+
/// # Panics
192+
///
193+
/// This function panics if `T` is a Zero-Sized Type (“ZST”).
194+
///
191195
/// # Caveat
192196
///
193197
/// 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] {
247251
///
248252
/// Note that a range created from [`slice::as_mut_ptr_range`] fulfills these requirements.
249253
///
254+
/// # Panics
255+
///
256+
/// This function panics if `T` is a Zero-Sized Type (“ZST”).
257+
///
250258
/// # Examples
251259
///
252260
/// ```

0 commit comments

Comments
 (0)