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

Explain closures much better in the tutorial #13621

Closed
mdinger opened this issue Apr 19, 2014 · 2 comments · Fixed by #13676
Closed

Explain closures much better in the tutorial #13621

mdinger opened this issue Apr 19, 2014 · 2 comments · Fixed by #13676
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@mdinger
Copy link
Contributor

mdinger commented Apr 19, 2014

Basically, I didn't think the tutorial helped much at all to explain closures so I tried to understand it and make changes so that it is clearer. Guys on IRC helped answer my questions so I think hope what I changed is pretty accurate.

I'll probably try to do more but I wanted to put this up so people could see. I think it's much better. They're all in this commit.

mdinger@b580964

Let me be clear, from reading the tutorial earlier, it wasn't obvious b: |int| had anything to do with a function. I thought it meant an int was gonna be assigned to b. All the vertical bars did was make it special.

@flaper87
Copy link
Contributor

part of #11755

@mdinger
Copy link
Contributor Author

mdinger commented Apr 20, 2014

I think this should be much better than before. Perhaps some more complex examples should be included.

I tried to get their stack closure example to println!() but it complained about ownership. Stack closure is also mentioned as one alternative of many but they don't specify any others. I asked on IRC and was basically told that closures alternatives are subject to change.

mdinger@d67b1b2

@mdinger mdinger mentioned this issue Apr 22, 2014
bors added a commit that referenced this issue May 4, 2014
Improve tutorial discussion of closures, e.g. with respect to type inference and variable capture.

Fix #13621 

---- original description follows

I'd like this pulled to master if possible but if not I'd appreciate comments on what I need to change.  I found the closures difficult to understand as they were so I tried to explain it so I would've had an easier time understanding it.  I think it's better at least, somewhat.

I don't know that everyone liked the `-> ()` I included but I thought explicit is best to aid understanding.  I thought it was much harder to understand than it should have been.

[EDIT] - Clicked too early.
This doesn't `make check` without errors on my Xubuntu on Virtualbox machine.  Not sure why.  I don't think I changed anything problematic.  I'll try `make check` on master tomorrow.

Opened #13621 regarding this.
arcnmx pushed a commit to arcnmx/rust that referenced this issue Dec 17, 2022
…as-schievink

fix: make make_body respect comments in extract_function

Possible fix for rust-lang#13621

### Points to help in review:

- Earlier we were only considering statements in a block expr and hence comments were being ignored, now we handle tokens hence making it aware of comments and then preserving them using `hacky_block_expr_with_comments`

Seems like I am not able to attach output video, github is glitching for it :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants