File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -226,12 +226,28 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
226226 mem:: forget ( tmp) ;
227227}
228228
229- /// Swaps a sequence of values at two mutable locations of the same type.
229+ /// Swaps `count * size_of::<T>()` bytes between the two regions of memory
230+ /// beginning at `x` and `y`. The two regions must *not* overlap.
230231///
231232/// # Safety
232233///
233- /// The two arguments must each point to the beginning of `count` locations
234- /// of valid memory, and the two memory ranges must not overlap.
234+ /// Behavior is undefined if any of the following conditions are violated:
235+ ///
236+ /// * Both `x` and `y` must be [valid].
237+ ///
238+ /// * Both `x` and `y` must be properly aligned.
239+ ///
240+ /// * `x.offset(count)` must be [valid]. In other words, the region of memory
241+ /// which begins at `x` and has a length of `count * size_of::<T>()` bytes
242+ /// must belong to a single, live allocation.
243+ ///
244+ /// * `y.offset(count)` must be [valid]. In other words, the region of memory
245+ /// which begins at `y` and has a length of `count * size_of::<T>()` bytes
246+ /// must belong to a single, live allocation.
247+ ///
248+ /// * The two regions of memory must *not* overlap.
249+ ///
250+ /// [valid]: ../ptr/index.html#safety
235251///
236252/// # Examples
237253///
You can’t perform that action at this time.
0 commit comments