-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add examples to TyKind::FnDef
and TyKind::FnPtr
docs
#54781
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
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.
Thanks, I think this improves the readability! Just a couple of small comments to tweak it a little more.
src/librustc/ty/sty.rs
Outdated
@@ -127,9 +127,26 @@ pub enum TyKind<'tcx> { | |||
|
|||
/// The anonymous type of a function declaration/definition. Each | |||
/// function has a unique type. |
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.
Maybe you could also clarify the output syntax here.
/// The anonymous type of a function declaration/definition. Each
/// function has a unique type, which is output (for a function
/// named `foo` returning an `i32`) as `fn() -> i32 {foo}`.
src/librustc/ty/sty.rs
Outdated
/// ```rust | ||
/// fn foo() -> i32 { 1 } | ||
/// | ||
/// fn hello() { |
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.
I think you can get away with just writing it on two lines, which saves a little space:
fn foo() -> i32 { 1 }
let bar = foo; // bar: fn() -> i32 {foo}
Thanks for the review, it should be good now 👍 |
Thanks! @bors r+ rollup |
📌 Commit 769b383 has been approved by |
Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs This adds two examples to the docs of `TyKind::FnDef` and `TyKind::FnPtr`. I found these two types a bit confusing when I learned about them and I think adding these examples might help others.
Rollup of 11 pull requests Successful merges: - #54078 (Expand the documentation for the `std::sync` module) - #54717 (Cleanup rustc/ty part 1) - #54781 (Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs) - #54787 (Only warn about unused `mut` in user-written code) - #54804 (add suggestion for inverted function parameters) - #54812 (Regression test for #32382.) - #54833 (make `Parser::parse_foreign_item()` return a foreign item or error) - #54834 (rustdoc: overflow:auto doesn't work nicely on small screens) - #54838 (Fix typo in src/libsyntax/parse/parser.rs) - #54851 (Fix a regression in 1.30 by reverting #53564) - #54853 (Remove unneccessary error from test, revealing NLL error.) Failed merges: r? @ghost
This adds two examples to the docs of
TyKind::FnDef
andTyKind::FnPtr
.I found these two types a bit confusing when I learned about them and I think adding these examples might help others.