Skip to content

Commit c547e08

Browse files
committed
Improve safety warning on ptr::swap
1 parent 3191886 commit c547e08

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libcore/ptr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
7474
///
7575
/// # Safety
7676
///
77-
/// This is only unsafe because it accepts a raw pointer.
77+
/// This function copies the memory through the raw pointers passed to it
78+
/// as arguments, which means they will be dereferenced.
79+
///
80+
/// Ensure that these pointers are valid before calling `swap`.
7881
#[inline]
7982
#[stable(feature = "rust1", since = "1.0.0")]
8083
pub unsafe fn swap<T>(x: *mut T, y: *mut T) {

0 commit comments

Comments
 (0)