-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mem::replace and mem::swap say they don't copy, but they do #35935
Comments
It moves. Moves are in the end implemented by copying bytes, but that's not what "copy" means in most Rust contexts. |
They don't copy in Rust semantics, but we should rewrite them to talk about move semantics, which will make it easier for everyone to understand. These functions are not unsafe or tricky or anything, so we really don't need to reassure users about how they work (they will obey Rust's regular rules, of course)?
Not sure what to even say about swap. Maybe:
|
All that needs to happen here is update docs per @bluss. |
Yeah I wasn't saying the implementations had any problem. |
This update was prompted by @durka and the exact words are from @bluss. Part of rust-lang#35935. r? @brson
I also changed this wording in #36357. |
Thanks to @kmcallister 's work, giving this a close. |
mem::replace
:mem::swap
:However,
replace
callsswap
which usescopy_nonoverlapping
, making the docs technically false. Should it say "without cloning" or "without deep-copying" instead?The text was updated successfully, but these errors were encountered: