-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Document drop more. #42159
Document drop more. #42159
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
(Does this work?) |
@@ -153,6 +153,14 @@ use marker::Unsize; | |||
/// The `Drop` trait is used to run some code when a value goes out of scope. | |||
/// This is sometimes called a 'destructor'. | |||
/// | |||
/// When a value goes out of scope, if it implements this trait, it will have |
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.
This is a bit repetitive w.r.t "when a value goes out of scope".
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.
That's fine, as the first line is a summary, and this is the full explanation.
src/libcore/ops.rs
Outdated
/// | ||
/// Because of the recursive dropping, even for types that do not implement | ||
/// this trait, you do not need to implement this trait unless your type | ||
/// needs its own destructor logic. |
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.
"even for types that do not implement this trait, you do not need to implement this trait"
doesn't parse to me :)
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.
This is what happens when you stare at the screen for half an hour wondering what to write.
@@ -171,6 +179,44 @@ use marker::Unsize; | |||
/// let _x = HasDrop; | |||
/// } | |||
/// ``` | |||
/// | |||
/// Showing the recursive nature of `Drop`. When `outer` goes out of scope, the |
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.
First sentence is incomplete?
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.
Only as much as the first sentence to the previous example which says "A trivial implementation of Drop
".
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.
Yeah; I think this is fine, though personally, I tend to use fragments like this for the short ones, and since there's more here, I'd probably make it a full sentence. NBD
src/libcore/ops.rs
Outdated
/// | ||
/// Showing the recursive nature of `Drop`. When `outer` goes out of scope, the | ||
/// `drop` method will be called for `Outer` and then the `drop` method for | ||
/// `Inner` will be called. Therefore `main` prints `Dropping Outer!` and then |
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.
repetitive wording "the drop
method will be called for Outer
and then the drop
method for Inner
will be called."
Why not "the drop
method will be called first for Outer
, then for Inner
"
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.
Can do.
/// } | ||
/// ``` | ||
/// | ||
/// Because variables are dropped in the reverse order they are declared, |
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.
Is "declared" the right term here?
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.
yes
@@ -153,6 +153,14 @@ use marker::Unsize; | |||
/// The `Drop` trait is used to run some code when a value goes out of scope. | |||
/// This is sometimes called a 'destructor'. | |||
/// | |||
/// When a value goes out of scope, if it implements this trait, it will have |
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.
That's fine, as the first line is a summary, and this is the full explanation.
@@ -171,6 +179,44 @@ use marker::Unsize; | |||
/// let _x = HasDrop; | |||
/// } | |||
/// ``` | |||
/// | |||
/// Showing the recursive nature of `Drop`. When `outer` goes out of scope, the |
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.
Yeah; I think this is fine, though personally, I tend to use fragments like this for the short ones, and since there's more here, I'd probably make it a full sentence. NBD
/// } | ||
/// ``` | ||
/// | ||
/// Because variables are dropped in the reverse order they are declared, |
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.
yes
@bors: r+ rollup thanks so much! |
📌 Commit b41b294 has been approved by |
Document drop more. Adds two examples to Drop and describes the recursive drop on types that contain fields.
Document drop more. Adds two examples to Drop and describes the recursive drop on types that contain fields.
Document drop more. Adds two examples to Drop and describes the recursive drop on types that contain fields.
Document drop more. Adds two examples to Drop and describes the recursive drop on types that contain fields.
Document drop more. Adds two examples to Drop and describes the recursive drop on types that contain fields.
Document drop more. Adds two examples to Drop and describes the recursive drop on types that contain fields.
Document drop more. Adds two examples to Drop and describes the recursive drop on types that contain fields.
Document drop more. Adds two examples to Drop and describes the recursive drop on types that contain fields.
Adds two examples to Drop and describes the recursive drop on types that contain fields.