Skip to content

Rustdoc: List traits that a trait implements #37593

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
icefoxen opened this issue Nov 4, 2016 · 4 comments
Closed

Rustdoc: List traits that a trait implements #37593

icefoxen opened this issue Nov 4, 2016 · 4 comments
Labels
T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@icefoxen
Copy link
Contributor

icefoxen commented Nov 4, 2016

Basically, a struct will list all the methods and traits that it implements, but a trait will not. So while looking at the docs for a specific struct gets you complete info on what you can do with it, looking at the docs for a trait doesn't tell you anything about what other traits it brings along with it.

For example, IntoIter is implemented for Iterator, but there's no mention of this in the docs for the Iterator trait. So if you implement Iterator on a type you get IntoIter for free along with it but there's no way to discover this unless you dig doooooown through the docs for IntoIter.

Sorry if this is a duplicate.

@Stebalien
Copy link
Contributor

Stebalien commented Nov 4, 2016

Technically, traits don't actually implement anything (trait objects can but that's a different story). Instead, you have blanket impls bounded by a set of traits. That is:

 // Note: Implementations on generic type parameters are called "blanket impls"
impl<T> MyTrait for T where T: Trait1 + Trait2 ... { /* ... */ }

So, in this case, I believe you'd want the Trait1 and Trait2 documentation to list the MyTrait implementation.


I'm probably being a bit imprecise here. I believe trait object actually refers to &Trait. What do we call the unsized type Trait?

@bluss
Copy link
Member

bluss commented Nov 5, 2016

The unsized type Trait is the object type of the trait with the same name. (Sigh mislicked)

@bluss bluss closed this as completed Nov 5, 2016
@bluss bluss reopened this Nov 5, 2016
@Mark-Simulacrum Mark-Simulacrum added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-nominated T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. labels May 15, 2017
@Mark-Simulacrum
Copy link
Member

Nominating for T-dev-tools discussion (cc @nrc) since I think that this is something that would be amazing, but also likely quite difficult.

@Mark-Simulacrum
Copy link
Member

Closing in favor of #33772, thanks to @QuietMisdreavus who found it. No need to nominate that since it seems we've had sufficient discussion on this that we do want it very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants