improve documentation for Fn* traits#35810
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
src/libcore/ops.rs
Outdated
There was a problem hiding this comment.
I think you want to write "to take an mutable"
There was a problem hiding this comment.
I do indeed. Thank you! I'll go ahead and refactor these docs a bit now.
|
I've added some more documentation, more for form then contact at this point because I don't quite understand these traits yet. |
src/libcore/ops.rs
Outdated
There was a problem hiding this comment.
these should link to the traits
a5c99da to
cd0676c
Compare
|
This is now approaching a serious attempt at contribution. :P |
|
Nice! Seems good to me but I'll let @steveklabnik handles it. |
|
Actually, I believe my |
|
Okay, fixed. |
|
☔ The latest upstream changes (presumably #35857) made this pull request unmergeable. Please resolve the merge conflicts. |
b4c39df to
71b09eb
Compare
src/libcore/ops.rs
Outdated
There was a problem hiding this comment.
Perhaps x * 2? I associate doubling with multiplication (though the two are clearly equivalent).
I can think of a few things we may want to accomplish with the documentation of the `Fn`, `FnMut`, and `FnOnce` traits: - the relationship between these traits and the closures that implement them - examples of non-closure implementations - the relationship between these traits and Rust's ownership semantics add module-level documentation for `Fn*` traits Describe how `Fn*` traits, closure types, and ownership semantics are linked, and provide examples of higher-level functions that take `Fn*`s. more examples for `Fn*` traits create correct (though not yet elegant) examples for `FnMut` and `FnOnce` add trait links to module-level documentation third time's a charm! argument -> capture for trait documentation This wording will need to be supported with better examples for capturing eventually. correct `FnOnce` example I also fixed some of the trait wording here to make the concept of capturing clearer; though that still needs more work. replace `x + x` with `x * 2` for `fn double`
44a27df to
67b9cd3
Compare
|
@bors: r+ rollup thanks a lot! |
|
📌 Commit 67b9cd3 has been approved by |
|
⌛ Testing commit 67b9cd3 with merge 78f057b... |
|
💔 Test failed - auto-mac-64-opt-rustbuild |
|
@bors retry |
…steveklabnik improve documentation for `Fn*` traits This PR is not yet a serious attempt at contribution. Rather, I'm opening this for discussion. I can think of a few things we may want to accomplish with the documentation of the `Fn`, `FnMut`, and `FnOnce` traits: - the relationship between these traits and the closures that implement them - examples of non-closure implementations - the relationship between these traits and Rust's ownership semantics
This PR is not yet a serious attempt at contribution. Rather, I'm opening this for discussion. I can think of a few things we may want to accomplish with the documentation of the
Fn,FnMut, andFnOncetraits: