mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-08 13:02:50 +00:00
clarify safety documentation of ptr::swap and ptr::copy
This commit is contained in:
parent
3071e0aef6
commit
b9c15c5d3b
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user