-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Unify closure and block #2824
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
Comments
I'm pretty sure that
Is going to mean async closures. Also, with generalized type ascription, we can insert type hints anywhere. |
That's what I mean by Title, unify closure and block, in my opinion: block just closures without arguments, but it could also use "arguments" outside of it's scope which could treat as arguments as well. So just unify these two types, make block a special closure. |
Unifying the the two would break let a = async { 1 };
let b = async || { 1 }; The type of |
Just a closure instant called, didn't break at all |
Also, Rust already has control flow like |
@CGQAQ so what happens with let b = async || { 1 };
b().await;
b().await; under this proposal |
When you . await a closure, compiler will try to convert it to a block
|
Forget it, won't work |
Uh oh!
There was an error while loading. Please reload this page.
Motivation: make Rust more explicit , consistent and sovle this issue
The idea is basically like
every block could written as closure so can specify return type and parameters(will explain in detail later)
Async block return type infer issue
This will raise compilation error:
with my proposal, will become like this:
Now you would think, what's the point about ||, it's the second use case about my proposal: make Rust a more expilict language.
In rust, almost every block could
return a value
, and could use some variables outset of itselfWith my proposal, every block is just same as closure, you can do this if you want instead of change
a
to&a
everywhere:Of cause all is optional, just specify if you need
The text was updated successfully, but these errors were encountered: