File tree 1 file changed +19
-3
lines changed
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) {
226
226
mem:: forget ( tmp) ;
227
227
}
228
228
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.
230
231
///
231
232
/// # Safety
232
233
///
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
235
251
///
236
252
/// # Examples
237
253
///
You can’t perform that action at this time.
0 commit comments