-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Try to improve PhantomData docs with more examples #24059
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
Try to improve PhantomData docs with more examples #24059
Conversation
/// | ||
/// Adding a field of type `PhantomData<T>` also indicates that your | ||
/// struct owns data of type `T` and hence may drop one or more | ||
/// instances of the type `T` could be dropped when instances of 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.
"may drop" and "could be dropped" are redundant here.
👍 |
/// intent is not expressed in the code, since there are no uses of | ||
/// the lifetime `'a` and hence it is not clear what data it applies | ||
/// to. We can correct this by telling the compiler to act *as if* the | ||
/// `Slice` struct contained a borrowed reference `&'a T`: |
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.
Using *mut T
and then acting as if it were a &T
(the mut
vs. not, specifically) is mildly disconcerting.
r=me with @apasel422's grammar note, and my |
2d708b0
to
d166772
Compare
📌 Commit d166772 has been approved by |
(Incorporated feedback.) |
…a-docs, r=huon This probably needs a bit more work, but I wanted to try and capture some common use cases and be a bit more helpful. r? @huonw cc @steveklabnik
needs ae64d8e |
This probably needs a bit more work, but I wanted to try and capture some common use cases and be a bit more helpful.
r? @huonw
cc @steveklabnik