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

Closure type annotation language may need to use more weasel words #2837

Closed
carols10cents opened this issue Aug 23, 2021 · 1 comment
Closed
Milestone

Comments

@carols10cents
Copy link
Member

I just ran into a problem where closure parameter types needed to be annotated to get the code to compile. The issue hasn't seen much activity, and I'm not sure whether it's expected behavior or not. But I'd like to check in on this when I'm editing the closures chapter to see if we need to dial back a bit on some statements' absoluteness, like:

Closures don’t require you to annotate the types of the parameters or the return value like fn functions do.

Within these limited contexts, the compiler is reliably able to infer the types of the parameters and the return type

As with variables, we can add type annotations if we want to increase explicitness and clarity at the cost of being more verbose than is strictly necessary.

@carols10cents carols10cents added this to the ch13 milestone Aug 23, 2021
@steveklabnik
Copy link
Member

I have run into this from time to time as well, often when returning Results from a closure. I still think it's rare enough we don't have to add more weasel words, but it couldn't hurt :)

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

2 participants