Skip to content

Doc: Clarify the meaning of "copy" in std::mem::swap/replace #18008

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

Closed
wants to merge 18 commits into from
Closed

Doc: Clarify the meaning of "copy" in std::mem::swap/replace #18008

wants to merge 18 commits into from

Conversation

jrgold
Copy link

@jrgold jrgold commented Oct 13, 2014

The use of "without copying" in the std::mem docs was a source of confusion to those less familiar with Rust, as it could refer to either semantic copying or byte copying. This clarifies which meaning was intended.

ruuda and others added 11 commits October 9, 2014 00:32
The Windows-specific instruction under 'Quick Start' linked the wiki article on getting started developing Rust itself, but the quick start is just about obtaining a working Rust installation. The actual wiki page with Windows-specific instructions was difficult to find.
The Sieve algorithm only requires checking all elements up to and including the square root of the maximum prime you're looking for. After that, the remaining elements are guaranteed to be prime.
Added 64-bit Windows support to the list of platforms. Support for 64-bit Windows was added in Rust 0.12.0. See  https://mail.mozilla.org/pipermail/rust-dev/2014-October/011267.html for the release notes.
std::mem::replace by adding a distinction between semantic and byte copies.
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

@Gankra
Copy link
Contributor

Gankra commented Oct 13, 2014

A shallow byte-level copy is what a Copy is, no? I think this might be more confusing.

bors added 4 commits October 13, 2014 17:42
Added 64-bit Windows support to the list of platforms. Support for 64-bit Windows was added in Rust 0.12.0. See  https://mail.mozilla.org/pipermail/rust-dev/2014-October/011267.html for the release notes.
This is *heavily* based on `if let` (#17634) by @jakub- and @kballard

This should close #17687
The Windows-specific instruction under 'Quick Start' linked the wiki article on getting started developing Rust itself, but the quick start is just about obtaining a working Rust installation. The actual wiki page with Windows-specific instructions was difficult to find.

The most important thing to note on Windows is that you need mingw-builds, and it is totally not obvious. The only place where I have seen it mentioned is the wiki page, which was difficult to find before.
The Sieve algorithm only requires checking all elements up to and including the square root of the maximum prime you're looking for. After that, the remaining elements are guaranteed to be prime.
@jrgold
Copy link
Author

jrgold commented Oct 14, 2014

I guess it is a bit confusing, as Copy is for shallow byte copy-able types. I was trying to use the terminology used in this reddit thread: http://redd.it/2j1vqa. /u/dbaupp talks about the distinction in their comment. I'll have a think about a way to succinctly clarify the distinction.

@Gankra
Copy link
Contributor

Gankra commented Oct 14, 2014

CC @huonw are you happy with this wording going into the docs?

@reem
Copy link
Contributor

reem commented Oct 14, 2014

How about without cloning either one. We use clone to mean semantic copy elsewhere and in regular discussion.

@jrgold
Copy link
Author

jrgold commented Oct 14, 2014

Using clone instead of semantic copy sounds like a good solution to me - it removes the confusion over the meaning of "copy".

@pnkfelix
Copy link
Member

(I'd say "without recursively copying" myself, rather than "without semantically copying". I don't know why I prefer the former over "clone" ... maybe I need to see more of the spots that @reem is referring to; I usually think of clone as talking specifically about the method on the Clone trait.)

@jrgold
Copy link
Author

jrgold commented Oct 14, 2014

Are there ways to recursively copy other than by using clone? If not, I'd say it makes sense to include clone for consistency's sake. "Recursively copy" instead of "semantically copying" sounds like a good change to me either way.

@reem
Copy link
Contributor

reem commented Oct 14, 2014

Since we attach "semantic copy" to the Clone trait, I think it's an appropriate use of the term.

You could say that this "swaps the values at two memory locations without dropping either one, using only shallow copies."

@huonw
Copy link
Member

huonw commented Oct 14, 2014

FWIW, "semantic copy" is just terminology I have been using to describe the difference (the first time I know it was used was this SO answer of mine), it's not really attached to Clone. Of course, we can always connect that name to Clone.

To be clear, I'm very happy with using the terminology in the docs, but I'm also happy with "clone" or "recursively copying".

std::mem::replace by adding a distinction between semantic and byte copies.
Changes this terminology in the docs for std::mem::swap and std::mem::replace.
Adds a reference to Clone in regards to recursive copying in these docs.
…into doc-mem-copy-meaning

Conflicts:
	src/libcore/mem.rs
@jrgold
Copy link
Author

jrgold commented Oct 14, 2014

Alright I've updated the wording of the changed documentation with everyone's suggestions. I think I may have done something wrong in the process of committing/pulling though, so I apologize if I've made anything difficult for anyone, I'm totally new to git and github.

@alexcrichton
Copy link
Member

@jrgold looks like this picked up a lot of extra commits, you may want to do something like this to start over:

git checkout doc-mem-copy-meaning
git reset --hard origin/master
git cherry-pick 847ed00
git cherry-pick 7fe313b

@Gankra
Copy link
Contributor

Gankra commented Nov 8, 2014

@jrgold what's your status?

@jrgold
Copy link
Author

jrgold commented Nov 8, 2014

Sorry, I've been really caught up with final exams these past few weeks, and I didn't want to risk doing something wrong here in case I didn't have the time to fix it.

I've taken the steps @alexcrichton listed on my local copy. I'm unsure as to what other steps I need to take before pushing again; the development policy note talks about rebasing against master, but I'm not sure if that's only for the initial push before I made the pull request (I think I mucked this up before, which is what pulled in all those extra commits).

@Gankra
Copy link
Contributor

Gankra commented Nov 8, 2014

If it's been a while, it's good policy to rebase against master in case someone's come by and changed things since. But this is up to your discretion as long as everything merges and checks.

@steveklabnik
Copy link
Member

Yes, this will not merge without being rebased.

@alexcrichton
Copy link
Member

Closing due to inactivity (and @bors's queue is quite full!). Feel free to reopen with a rebase!

lnicola pushed a commit to lnicola/rust that referenced this pull request Sep 25, 2024
internal: Improve inlay hint resolution reliability

The payload now ships the range the inlay hint ought to be triggered for instead of trying to estimate it from its position which is somewhat brittle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.