Skip to content
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 traits from #[derive(...)] #4406

Closed
dns2utf8 opened this issue Aug 15, 2017 · 3 comments
Closed

Document traits from #[derive(...)] #4406

dns2utf8 opened this issue Aug 15, 2017 · 3 comments

Comments

@dns2utf8
Copy link

While documenting every public function of ThreadPool I had to implement #[derive(Clone) manually so I would be able to add an example.

I assume cargo doc has a default template for the derive-able traits.
So I propose something like this:

#[derive(Clone)
/// My custom doc
/// ```
/// let my = custom.example();
/// ```
#[derive(PartialEq, Eq)
/// My custom doc for both traits
/// ```
/// let my = custom.example();
/// ```
struct CustomStruct;

The template would have to include something like "yield" within the code it is generating.
In this case it should generate something equal to:

impl Clone for CustomStruct {
    /// My custom doc
    /// ```
    /// let my = custom.example();
    /// ```
    fn clone(&self) -> Self { CustomStruct }
}
/* similar for the other two traits */
struct CustomStruct;

What do you think?

@alexcrichton
Copy link
Member

Thanks for the report! I think though this may be best located on the rust-lang/rust repo perhaps instead of Cargo?

@carols10cents
Copy link
Member

Yep, this sounds like a job for rustdoc since cargo doc mostly just calls rustdoc. @dns2utf8 I've taken the liberty of moving this issue over to rust-lang/rust#44118 for you!

@dns2utf8
Copy link
Author

Thank you 👍

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

No branches or pull requests

3 participants