Skip to content

Misleading section on angle-brackets for specializing traits in Generic functions section #26320

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
simendsjo opened this issue Jun 15, 2015 · 2 comments

Comments

@simendsjo
Copy link

In the reference.md in the section Generic functions it is stated that

Each type parameter must be explicitly declared, in an angle-bracket-enclosed, comma-separated list following the function name.

(emphasis mine)

But the example shows a type parameter on Fn, which requires parenthesis-enclosed type parameters rather than angle-brackets. geofft mentioned on IRC that this might be some special case to open the possibility to easier change the Fn traits at a later time (if I understood correctly), but I found it confusing to see a specialization using parenthesis without ever having heard they existed.

@steveklabnik
Copy link
Member

Isn't the text referring to

fn iter<T, F>

Those angle brackets? "following the function name"

@geofft
Copy link
Contributor

geofft commented Jun 15, 2015

Yeah, I suspect the real confusion here is that the Fn() syntax with parens has not yet been introduced (nor is it explained anywhere, apparently), so it's the wrong example at this point in the document, and it's not clear to a first-time reader what is being referred to. It seems like there should be a sufficient example here that doesn't use closures, maybe one simple one with println! and Display, and one using traits over collections or iterators or something, to demonstrate that parameterized types can appear in the bounds, to make it easier to understand.

That said, the reference is explicitly not intended to be pedagogical, and implicitly not yet expected to be complete.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jun 15, 2015
dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
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