Skip to content

Re-write closures chapter#23568

Merged
alexcrichton merged 1 commit intorust-lang:masterfrom
steveklabnik:closure_docs
Apr 2, 2015
Merged

Re-write closures chapter#23568
alexcrichton merged 1 commit intorust-lang:masterfrom
steveklabnik:closure_docs

Conversation

@steveklabnik
Copy link
Contributor

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per rust-lang/rfcs#968 braces will be required here.

@mdinger
Copy link
Contributor

mdinger commented Mar 21, 2015

On the whole, I think this is very informative. It's use of Box, traits, and various dispatch types seems to reinforce the idea that in Rust, there are a few important ideas which extend to be very encompassing and cohesive. It's not just a disparate set of parts cobbled together in odd ways. Some parts of the language probably feel more this way than others.

Little was said about the differences between Fn, FnMut, FnOnce. That's the only other thought I had.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one warning: I expect that the fix for #23319 will cause this not to work unless you annotate the type of x (|x: i32|)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. let's see which one lands first, I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it's still working

@steveklabnik
Copy link
Contributor Author

Added some commits to address some of the additional stuff. I think I'll wait till #23282 to land before I polish the rest off, since that changes some things.

@Manishearth
Copy link
Member

(#23282 landed)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a comma splice in this sentence - how about:

Anonymous functions which have an associated environment are called 'closures' since they 'close' over their environment. Rust has a flexible implementation of closures that centers around overloading the calling operator: ().

You might want to drop the bit about (), but I just wanted to say something else in that sentence other than "the rust version is cool."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introductions are hard. I re-worded this slightly, but don't know what exactly to add. I'm not sure describing it as () overloading really captures what I love about closures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.