Skip to content

Adding a PhantomData example. #22945

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

Conversation

golddranks
Copy link
Contributor

There was a FIXME in the PhantomData documentation, demanding more/better examples. I have recently used PhantomData this way, so I thought this could maybe do as an example.

r? @steveklabnik

@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 @steveklabnik (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 CONTRIBUTING.md for more information.

@@ -351,7 +351,35 @@ pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
/// instance, it will behave *as if* an instance of the type `T` were
/// present for the purpose of various automatic analyses.
///
/// For example, embedding a `PhantomData<T>` will inform the compiler
/// # Example
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use 'Examples' for everything, even if there's just one. And, there needs to be a newline after it as well.

@steveklabnik
Copy link
Member

Hey @golddranks , thank you for the PR! I have a few nits, but I'm happy with this overall. @nikomatsakis , what do you think?

@nikomatsakis
Copy link
Contributor

@bors r+ 6eb5a37

lgtm!

@nikomatsakis
Copy link
Contributor

@bors rollup

@Manishearth
Copy link
Member

This doesn't pass doctests

http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/3982/steps/test/logs/stdio

Could you ensure that make check-stage1-doc-crate-core passes?

@Manishearth
Copy link
Member

@bors: r-

@steveklabnik steveklabnik mentioned this pull request Mar 8, 2015
Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 8, 2015
bors added a commit that referenced this pull request Mar 8, 2015
@bors
Copy link
Collaborator

bors commented Mar 9, 2015

☔ The latest upstream changes (presumably #23179) made this pull request unmergeable. Please resolve the merge conflicts.

@golddranks
Copy link
Contributor Author

Said this on IRC:
< drasa> steveklabnik: Ah, sorry, I just noticed you pulled in the PR of PhantomData
example, I was actually unaware that code examples in the comments were
tested too, so I hadn't added the "invisible" lines so that the tests would
pass. I just learned that today, and was going to fix it, sorry for the
trouble!

Closing this :)

@golddranks golddranks closed this Mar 9, 2015
@golddranks golddranks deleted the add_phantomdata_example branch March 9, 2015 12:38
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.

6 participants