clarify safety documentation of ptr::swap and ptr::copy

This commit is contained in:
Ralf Jung 2023-08-14 09:40:09 +02:00
parent 3071e0aef6
commit b9c15c5d3b
2 changed files with 6 additions and 0 deletions

View File

@ -2709,6 +2709,9 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
///
/// * `dst` must be [valid] for writes of `count * size_of::<T>()` bytes.
///
/// * `src` must remain valid for reads even after `dst` is written, and vice versa.
/// (In other words, there cannot be aliasing restrictions on the use of these pointers.)
///
/// * Both `src` and `dst` must be properly aligned.
///
/// Like [`read`], `copy` creates a bitwise copy of `T`, regardless of

View File

@ -797,6 +797,9 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
///
/// * Both `x` and `y` must be [valid] for both reads and writes.
///
/// * `x` must remain valid for reads and writes even after `y` is read/written, and vice versa.
/// (In other words, there cannot be aliasing restrictions on the use of these pointers.)
///
/// * Both `x` and `y` must be properly aligned.
///
/// Note that even if `T` has size `0`, the pointers must be non-null and properly aligned.