-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rustdoc: Explain the copy trait more clearly (doc book) #25898
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
Conversation
As mentioned in #25893 the copy trait is not very well explained for beginners. There is no clear mention that all primitive types implement the copy trait and there are not a lot of examples. With this change I try to make it more visible and understandable for new users. I myself have struggled with this, see [my question on stackoverflow](http://stackoverflow.com/questions/30540419/why-are-booleans-copyable-even-though-the-documentation-doesnt-indicate-that). And I want to make it more transparent for others. I filed issue #25893 but I thought that I could give it a shot myself to relieve some of the work from the devs :) If it is not well written or there are some changes to be made before it can be merged, let me know. Cheers, Mathieu
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. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@@ -156,6 +156,49 @@ that, just like a move, when we assign `v` to `v2`, a copy of the data is made. | |||
But, unlike a move, we can still use `v` afterward. This is because an `i32` | |||
has no pointers to data somewhere else, copying it is a full copy. | |||
|
|||
All primitive types implement the `Copy` trait and their ownership is | |||
therefore not moved like one would assume, following the **ownership rules**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've been using curly 's to indicate this, not bold
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with curly's?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not '
, but ‘
and ’
. See ‘use of moved value’
a bit farther up on the page
@steveklabnik I updated with the asked changes, I hope all is good now :) |
@bors: r+ rollup |
📌 Commit 5efdcf2 has been approved by |
Thank you so much! |
As mentioned in rust-lang#25893 the copy trait is not very well explained for beginners. There is no clear mention that all primitive types implement the copy trait and there are not a lot of examples. With this change I try to make it more visible and understandable for new users. I myself have struggled with this, see [my question on stackoverflow](http://stackoverflow.com/questions/30540419/why-are-booleans-copyable-even-though-the-documentation-doesnt-indicate-that). And I want to make it more transparent for others. I filed issue rust-lang#25893 but I thought that I could give it a shot myself to relieve some of the work from the devs :) If it is not well written or there are some changes to be made before it can be merged, let me know. Cheers, Mathieu
As mentioned in #25893 the copy trait is not very well explained for beginners. There is no clear mention that all primitive types implement the copy trait and there are not a lot of examples.
With this change I try to make it more visible and understandable for new users.
I myself have struggled with this, see my question on stackoverflow. And I want to make it more transparent for others.
I filed issue #25893 but I thought that I could give it a shot myself to relieve some of the work from the devs :)
If it is not well written or there are some changes to be made before it can be merged, let me know.
Cheers,
Mathieu