Skip to content
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

Merged
merged 2 commits into from
Oct 6, 2018

Conversation

phansch
Copy link
Member

@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
Collaborator

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
Member

@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.

@@ -127,9 +127,26 @@ pub enum TyKind<'tcx> {

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

@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
Member

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
Member Author

phansch commented Oct 4, 2018

Thanks for the review, it should be good now 👍

@varkor
Copy link
Member

varkor commented Oct 5, 2018

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants