Uh oh!
There was an error while loading. Please reload this page.
Document behavior of ptr::swap with overlapping regions of memory. - #46483
Conversation
rust-highfive
commented
Dec 3, 2017
r? @BurntSushi (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
I don't think I understood the last sentence here until I looked at the example. Is there any way to write this more clearly? (The answer might be "no." I don't have any particularly good ideas.)
There was a problem hiding this comment.
another wording that comes to mind:
If the values do overlap, then the overlapping region of memory from
xtakes priority.
There was a problem hiding this comment.
That does actually seem better to me.
There was a problem hiding this comment.
adjusted in the latest force push
There was a problem hiding this comment.
I have to be honest, I didn't understand "takes priority" and I find the original wording better :/
There was a problem hiding this comment.
"will be used" is another possibility. It might also make sense to simply be like "see the example below" since this is definitely something an example clarifies greatly.
There was a problem hiding this comment.
applied @gankro's suggestions in the latest force push
--- a/src/libcore/ptr.rs+++ b/src/libcore/ptr.rs@@ -91,9 +91,12 @@ pub const fn null<T>() -> *const T { 0 as *const T }
pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
/// Swaps the values at two mutable locations of the same type, without
-/// deinitializing either. The values pointed at by `x` and `y` may overlap,-/// unlike `mem::swap` which is otherwise equivalent. If the values do overlap,-/// then the overlapping region of memory from `x` takes priority.+/// deinitializing either.+///+/// The values pointed at by `x` and `y` may overlap, unlike `mem::swap` which+/// is otherwise equivalent. If the values do overlap, then the overlapping+/// region of memory from `x` will be used. This is demonstrated in the+/// examples section below.
///
/// # Safety
///BurntSushi
commented
Dec 3, 2017
a870185 to
9e5b9abCompareGankra
commented
Dec 4, 2017
sgtm |
steveklabnik
commented
Dec 4, 2017
I'm also a little unsure about how to phrase this, but if we can't think of anything, we should |
9e5b9ab to
f366227Comparefrewsxcv
commented
Dec 6, 2017
anyone else have thoughts here? someone wanna approve this? |
BurntSushi
commented
Dec 6, 2017
bors
commented
Dec 6, 2017
📌 Commit f366227 has been approved by |
frewsxcv
commented
Dec 6, 2017
@bors rollup |
…Sushi Document behavior of `ptr::swap` with overlapping regions of memory. Fixesrust-lang#44479.
Fixes#44479.