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

@rust-highfive rust-highfive commented Oct 3, 2018

r? @varkor

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

Copy link
Member

@varkor varkor left a comment

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.

This comment has been minimized.

@varkor

varkor Oct 4, 2018
Member

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() {

This comment has been minimized.

@varkor

varkor Oct 4, 2018
Member

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 phansch force-pushed the phansch:master branch from 9dfd164 to 769b383 Oct 4, 2018
@phansch
Copy link
Member Author

@phansch phansch commented Oct 4, 2018

Thanks for the review, it should be good now 👍

@varkor
Copy link
Member

@varkor varkor commented Oct 5, 2018

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

@bors bors commented Oct 5, 2018

📌 Commit 769b383 has been approved by varkor

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
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.