-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Provide documentation for Default
impls
#23271
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
9f3cb03
to
0bf338f
Compare
@@ -51,5 +51,6 @@ impl<H> Clone for DefaultState<H> { | |||
} | |||
|
|||
impl<H> Default for DefaultState<H> { | |||
/// Creates a new `DefaultState` containing `marker::PhantomData` |
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.
PhantomData
is an implementation detail of DefaultState
. It shouldn't be documented.
779dded
to
a18037e
Compare
For the most part, the `Default` impls are pretty obvious as far as what we expect them to return, but I think it's better to explicitly state what's going to be returned in the documentation instead of relying on the user to make assumptions/look at the source.
@sfackler The latest force push look okay? |
In general, as you mention, we only document impls when it does something different than you'd expect. Given this rule, I'm not sure that this patch works. I will say that how Rustdoc should show trait stuff is very much under discussion, that's just the current way we handle things. |
@steveklabnik Just looking at the documentation, could you tell me what you'd 'expect' for the I don't see the harm in documenting what a function returns. |
Like most containers, I would expect it to consider the defaults of what it's generic over, which is exactly what it does.
I think the broader issue here isn't that more documentation is worse, it's just that we're unsure how to best do this documentation. And in my pull request for It's not that I think documentation is bad, it's just that consistency is also important. Maybe we should have a discussion about this topic in general. |
Since the current convention is not to do this, I'm going to give it a close. @frewsxcv , if you want to have a discussion, we could have one over in the RFCs repo about the pros and cons of changing the convention. |
@steveklabnik I'm not opposed this being closed, but for clarification, what convention are we talking about? Documenting |
The current convention is:
An example is |
Part of #36265. |
For the most part, the
Default
impls are pretty obvious as far as whatwe expect them to return, but I think it's better to explicitly state
what's going to be returned in the documentation instead of relying on
the user to make assumptions/look at the source.