Uh oh!
There was an error while loading. Please reload this page.
Added generic example of std::ops::Add in doc comments - #41612
Conversation
rust-highfive
commented
Apr 28, 2017
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
frewsxcv
commented
May 1, 2017
It seems like this example is being added to teach people how generic types work, which seems like a topic better suited for the book. That said, I imagine that using generic types when implementing @rust-lang/docs anyone else have opinions? |
mandeep
commented
May 1, 2017
@frewsxcv I agree, in fact the first edition of the book contains an example similar to the one in this PR. Rather than having to rummage through the book, I was thinking that something like this example should be able to be found in the API docs. What do you think? |
GuillaumeGomez
commented
May 1, 2017
Well, for me it's fine. It's just the trait |
GuillaumeGomez
left a comment
There was a problem hiding this comment.
Just little nits. Also, some comments in the code might help users.
There was a problem hiding this comment.
Added the empty lines and comment regarding Output=T. Let me know if you'd like to see anything else.
There was a problem hiding this comment.
We now have two extra lines. :p (remove 272 and 273)
There was a problem hiding this comment.
Should be followed by an empty line.
mandeep
commented
May 7, 2017
Thinking about this some more. Maybe this example is best left in the book instead of the std lib docs. Later on I imagine something like this could go into a cookbook as well. |
GuillaumeGomez
commented
May 8, 2017
I think it's a good thing to have it in multiple places. Can you just squash your commits please? Once done, I'll r+. |
mandeep
commented
May 8, 2017
Thanks! |
There was a problem hiding this comment.
I don't see any usage of the debug in the following code. Did you forget to remove it?
There was a problem hiding this comment.
The other examples derived Debug, so I followed the same path. Do you want me to remove Debug in this example and the other examples in std::Ops?
There was a problem hiding this comment.
Yes please (strange we kept them).
steveklabnik
commented
May 9, 2017
@GuillaumeGomez looks like this was updated |
GuillaumeGomez
commented
May 9, 2017
@steveklabnik: I commented on my previous review. |
mandeep
commented
May 11, 2017
Looks like Debug was needed on a couple of the tests? How should we move forward? |
GuillaumeGomez
commented
May 11, 2017
Put it where needed. My goal wasn't to force you to remove the |
mandeep
commented
May 11, 2017
My fault, I should have checked to see if Debug was needed. |
GuillaumeGomez
commented
May 11, 2017
Ok, all good. Please squash and then I merge. |
Added blank lines around example Added comment to Add example referencing the Output type Removed whitespace from lines 272 and 273 Removed Debug derivation from Add examples Added Debug derivation
frewsxcv
commented
May 13, 2017
@bors r=GuillaumeGomez,frewsxcv rollup |
bors
commented
May 13, 2017
📌 Commit a2a9d19 has been approved by |
…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.
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 #29365.