Skip to content

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

Merged
merged 1 commit into from
Apr 7, 2015

Conversation

nikomatsakis
Copy link
Contributor

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

///
/// 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
Copy link
Contributor

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.

@steveklabnik
Copy link
Member

👍

/// 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`:
Copy link
Member

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.

@huonw
Copy link
Member

huonw commented Apr 6, 2015

r=me with @apasel422's grammar note, and my mut-vs.-not nit (if you think it will improve it).

@nikomatsakis nikomatsakis force-pushed the issue-22914-phantomdata-docs branch from 2d708b0 to d166772 Compare April 6, 2015 13:39
@nikomatsakis
Copy link
Contributor Author

@bors r=huon rollup d166772

@bors
Copy link
Collaborator

bors commented Apr 6, 2015

📌 Commit d166772 has been approved by huon

@nikomatsakis
Copy link
Contributor Author

(Incorporated feedback.)

Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 7, 2015
…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
Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 7, 2015
@Manishearth
Copy link
Member

needs ae64d8e

@bors bors merged commit d166772 into rust-lang:master Apr 7, 2015
@nikomatsakis nikomatsakis deleted the issue-22914-phantomdata-docs branch March 30, 2016 16:14
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.

7 participants