-
Notifications
You must be signed in to change notification settings - Fork 256
"surprisingly hard things" #22
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
We should mention #![feature(async_await)]
use async_trait::async_trait;
#[async_trait]
trait View {
async fn render(&self);
}
struct Modal;
#[async_trait]
impl View for Modal {
async fn render(&self) {
self.render_fullscreen().await;
}
} |
hinting at error types in async blocks would be a good addition here: rust-lang/rust#63502 |
Another thing that would be good to include: https://users.rust-lang.org/t/mutexguard-cannot-be-sent-inside-future-generator/21584 the fact that the |
To extend the error types in async blocks, there are situations where the final annotated return triggers a warning, mentioned by @udoprog on Discord:
let future = async {
loop {
task().await?;
}
Ok::<_, Error>(())
}; eventually
|
@Nemo157 Could that be a type inference problem? The following code doesn't compile either: use std::fs::File;
fn main() {
let f = || {
File::open("a.txt")?;
Ok(())
};
}
If all uses of |
Yes, it's a type inference issue similar to the one @cramertj linked above (rust-lang/rust#63502). Until there is some way to specify the type (e.g. Even if |
Fixed by #36 |
|
In the async foundations meeting today we discussed the idea of adding a "surprisingly hard things" chapter that lists out tricky scenarios and the workarounds to help get people unstuck. The hope would be that most of these things will eventually be fixed in some way. =)
This issue is meant to collect some possible topics:
async fn
s are hard to makeSend
rust#62284)The text was updated successfully, but these errors were encountered: