Skip to content

Conversation

@phansch
Copy link
Contributor

@phansch phansch commented Oct 3, 2018

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.

@rust-highfive
Copy link
Contributor

r? @varkor

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 3, 2018
Copy link
Contributor

@varkor varkor left a 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.

Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability),

/// The anonymous type of a function declaration/definition. Each
/// function has a unique type.
Copy link
Contributor

@varkor varkor Oct 4, 2018

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}`. 
/// ```rust
/// fn foo() -> i32 { 1 }
///
/// fn hello() {
Copy link
Contributor

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}
@phansch
Copy link
Contributor Author

phansch commented Oct 4, 2018

Thanks for the review, it should be good now 👍

@varkor
Copy link
Contributor

varkor commented Oct 5, 2018

Thanks!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 5, 2018

📌 Commit 769b383 has been approved by varkor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 5, 2018
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.
bors added a commit that referenced this pull request Oct 6, 2018
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
@bors bors merged commit 769b383 into rust-lang:master Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

4 participants