Sync docs of slice::{from_ptr_range, from_ptr_range_mut}
This commit is contained in:
parent
bc1216e046
commit
2cd5fafd25
@ -223,9 +223,15 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
|
|||||||
unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
|
unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs the same functionality as [`from_ptr_range`], except that a
|
/// Forms a mutable slice from a pointer range.
|
||||||
|
///
|
||||||
|
/// This is the same functionality as [`from_ptr_range`], except that a
|
||||||
/// mutable slice is returned.
|
/// mutable slice is returned.
|
||||||
///
|
///
|
||||||
|
/// This function is useful for interacting with foreign interfaces which
|
||||||
|
/// use two pointers to refer to a range of elements in memory, as is
|
||||||
|
/// common in C++.
|
||||||
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// Behavior is undefined if any of the following conditions are violated:
|
/// Behavior is undefined if any of the following conditions are violated:
|
||||||
@ -255,6 +261,14 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
|
|||||||
///
|
///
|
||||||
/// This function panics if `T` is a Zero-Sized Type (“ZST”).
|
/// This function panics if `T` is a Zero-Sized Type (“ZST”).
|
||||||
///
|
///
|
||||||
|
/// # Caveat
|
||||||
|
///
|
||||||
|
/// The lifetime for the returned slice is inferred from its usage. To
|
||||||
|
/// prevent accidental misuse, it's suggested to tie the lifetime to whichever
|
||||||
|
/// source lifetime is safe in the context, such as by providing a helper
|
||||||
|
/// function taking the lifetime of a host value for the slice, or by explicit
|
||||||
|
/// annotation.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
Loading…
Reference in New Issue
Block a user