-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
API Docs: std::ops #29365
Comments
Currently most of the operator traits use trivial implementation examples that only perform side effects. Honestly, that might not be too bad for the sake of documentation; but anyway, here's a proposal to move a slightly modified version of the module-level point-addition example into the `Add` documentation, since it's more evocative of addition semantics. Part of rust-lang#29365 wrap identifiers in backticks minor rephrasing fix module-level documentation to be more truthful This branch changes the example for `Add` to no longer be a "minimum implementation that prints something to the screen".
Part of rust-lang#29365 explain that std::mem::drop in prelude will invoke Drop change "prelude" -> "the prelude"; change links to reference-style move link references to links' section
…=GuillaumeGomez replace `Add` example with something more evocative of addition Currently most of the operator traits use trivial implementation examples that only perform side effects. Honestly, that might not be too bad for the sake of documentation; but anyway, here's a proposal to move a slightly modified version of the module-level point-addition example into the `Add` documentation, since it's more evocative of addition semantics. Part of rust-lang#29365
…veklabnik note that calling drop() explicitly is a compiler error Part of rust-lang#29365
…=GuillaumeGomez replace `Add` example with something more evocative of addition Currently most of the operator traits use trivial implementation examples that only perform side effects. Honestly, that might not be too bad for the sake of documentation; but anyway, here's a proposal to move a slightly modified version of the module-level point-addition example into the `Add` documentation, since it's more evocative of addition semantics. Part of rust-lang#29365
…veklabnik note that calling drop() explicitly is a compiler error Part of rust-lang#29365
…=GuillaumeGomez replace `Add` example with something more evocative of addition Currently most of the operator traits use trivial implementation examples that only perform side effects. Honestly, that might not be too bad for the sake of documentation; but anyway, here's a proposal to move a slightly modified version of the module-level point-addition example into the `Add` documentation, since it's more evocative of addition semantics. Part of rust-lang#29365
…veklabnik note that calling drop() explicitly is a compiler error Part of rust-lang#29365
…=GuillaumeGomez replace `Add` example with something more evocative of addition Currently most of the operator traits use trivial implementation examples that only perform side effects. Honestly, that might not be too bad for the sake of documentation; but anyway, here's a proposal to move a slightly modified version of the module-level point-addition example into the `Add` documentation, since it's more evocative of addition semantics. Part of rust-lang#29365
…veklabnik note that calling drop() explicitly is a compiler error Part of rust-lang#29365
…veklabnik note that calling drop() explicitly is a compiler error Part of rust-lang#29365
…=GuillaumeGomez replace `Add` example with something more evocative of addition Currently most of the operator traits use trivial implementation examples that only perform side effects. Honestly, that might not be too bad for the sake of documentation; but anyway, here's a proposal to move a slightly modified version of the module-level point-addition example into the `Add` documentation, since it's more evocative of addition semantics. Part of rust-lang#29365
These examples are exactly analogous to those in PRs rust-lang#35709 and rust-lang#35806. I'll probably remove the `fn main` wrappers for `Add` and `Sub` once this is merged in. Part of rust-lang#29365. r? @steveklabnik
…laumeGomez more evocative examples for `Sub` and `SubAssign` These examples are exactly analogous to those in PRs rust-lang#35709 and rust-lang#35806. I'll probably remove the `fn main` wrappers for `Add` and `Sub` once this is merged in. Part of rust-lang#29365. r? @steveklabnik
Add missing urls for ops module Part of rust-lang#29365. r? @steveklabnik
I'd like to give this a go. Is there a getting started guide to contributing docs changes? |
@theotherphil great!
We have https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#writing-documentation, but I'd like to add more :) For example, https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md is a big list of conventions, though you don't need to really know them well to submit PRs; we'll make sure it follows them in the review. As far as this specific stuff goes, https://github.com/rust-lang/rust/blob/master/src/libcore/ops.rs is the file you'll want to edit; everything here should be in there. I'm happy to elaborate with more detail, but that should maybe get you started? 😄 |
Great, thanks. |
Don't stutter in operator trait descriptions Fixes first item on rust-lang#29365. r? @steveklabnik
Don't stutter in operator trait descriptions Fixes first item on rust-lang#29365. r? @steveklabnik
I'd like to help on this too. @theotherphil, which of the sub-issues are you working on/ want to work on? |
@terrynsun: I've done the first issue and have started to think a little about the next five (i.e. all the RangeX) issues. I've not looked at the others - do you want to do those? (Or split the work any other way?) |
I can take a shot at Deref/DerefMut/Drop. |
I'll be working on the last item in the list. Specifically, adding examples of implementing traits with generics. |
…meGomez,frewsxcv Added generic example of std::ops::Add in doc comments We discussed on IRC how the std::ops examples were potentially missing examples using generics. This PR adds an example to std::ops::Add that shows the use of a generic type T. I'm not sure this is ready for merge as I think the two examples now make the documentation a bit verbose, but I think it's a good starting point. I'd love to hear others thoughts on this. This is in relation to the last item in issue rust-lang#29365.
I'm working on getting as much of this done as I can in the next few days; I've already noticed quite a few examples implement |
Improve std::ops docs Fixes #29365. (This fixes all but one point from @steveklabnik's list, but that point was referring to examples of implementing range traits, but there are no range traits in std::ops.) The main changes are quite a bit of copyediting, adding more "real" examples for some of the traits, incorporating some guidance from the API docs, more linking (cross-docs and to the book & reference), cleaning up examples, moving things around, and so on. Refer to the commit messages for more details. Note: I decided to link to the second edition of the book since I think it's more appropriate now for the sections I linked, if this is not okay, please say so!
Part of #29329
http://doc.rust-lang.org/std/ops/
Here's what needs to be done to close out this issue:
Range
needs a better summary/explanation distinction.RangeFrom
has the same issue.RangeFull
sameRangeTo
sameDeref
is a very important trait with little documentation.DerefMut
should link toDeref
, and vice versa.Drop
is very important yet has little documentation.Fn
has a bad summary and a lot of its explanation is inside of the example.FnMut
sameFnOnce
sameThe text was updated successfully, but these errors were encountered: