Skip to content

Guide chapter on Closures is inconsistent and incomplete #20667

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

Closed
jsgf opened this issue Jan 6, 2015 · 1 comment
Closed

Guide chapter on Closures is inconsistent and incomplete #20667

jsgf opened this issue Jan 6, 2015 · 1 comment

Comments

@jsgf
Copy link
Contributor

jsgf commented Jan 6, 2015

The Guide's discussion of Closures has several problems:

It doesn't explain the |&:| syntax at all. The examples have been updated to use it, but the prose still just talks about "||". I think this is the right place to clarify what |:|, |&:| and |&mut:| mean, and perhaps how they relate to the Fn traits (which I don't really understand, which I was looking here for clarification).

The example using "twice()" uses two different syntaxes. First it says:

 fn twice<F: Fn(i32) -> i32>(x: i32, f: F) -> i32 {

but later it says

fn twice(x: i32, f: |i32| -> i32) -> i32 {

Are these equivalent?

I understand this is still in flux, and I gather the |:| syntax is going to go away (?) or become mostly optional(?) - either way, a paragraph with a bit of explanation would be useful.

@steveklabnik
Copy link
Member

Closing as a dup of #19841

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

No branches or pull requests

3 participants