-
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
Document what Default
does for each type in libstd
#36265
Comments
I'm thinking about where a good place would be to document this behavior. I'm leaning towards documenting these behaviors in the documents for each individual type, as opposed to in the docs for |
It would be nice if the comments were near the Default impl so they don't become stale (obviously they won't for primitive types, but this would be a good convention for user types as well). It could be a good addition to the "built-in traits section" that's been occasionally suggested for Rustdoc. Somewhere near the top it would say, e.g.:
And it would somehow gather this information from comments on the impl. |
@cbreeden I was thinking on the Default-impl for each type. For example for a slice, it would show up on this impl or on this method (depending on what works right now). https://doc.rust-lang.org/std/primitive.slice.html#method.default You can see that the Index impls for slice have specific documentation for the slice itself. |
I would like to take up this task and would like to get an explanation of how to go about it. |
@athulappadan: Find all the impl Default for String {
/// Create an empty `String`.
fn default() -> String {
String::new() // I guess it's doing this
}
} So in the example above, the thing you need to add is "Create an empty |
@athulappadan Don't miss this document when starting out. And feel free to ask questions https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md |
@athulappadan Any update on this issue? If not I might like to work on it. |
I was a bit busy. Will submit a PR tomorrow. |
Part of rust-lang#36265. These are all the instances of `Default` in this repository that are of the form `impl Default for X`. The default for `i32`, for example, is not of this form. @GuillaumeGomez
Documentation of what Default does for each type Addresses rust-lang#36265 I haven't changed the following types due to doubts: 1)src/libstd/ffi/c_str.rs 2)src/libcore/iter/sources.rs 3)src/libcore/hash/mod.rs 4)src/libcore/hash/mod.rs 5)src/librustc/middle/privacy.rs r? @steveklabnik
@athulappadan : Can this be closed? |
One more in #38186 |
Add docs for last undocumented `Default` `impl`. Add doc comment for `Default` `impl` on `DefaultHasher`. Fixes rust-lang#36265.
Add docs for last undocumented `Default` `impl`. Add doc comment for `Default` `impl` on `DefaultHasher`. Fixes rust-lang/rust#36265.
Document what
Default
does for each type in libstd.For example, for the
Default
impl for i32, mention that it returns 0. For slice, mention it returns an empty slice.The text was updated successfully, but these errors were encountered: