task::spawn(async move {
loop {
if let Err(err) = some_fallible_future.await {
return Err::<Infallible, _>(err);
}
}
});
Is it currently possible on stable to disambiguate the return type of the async block? I'd like to be able to write some_fallible_future.await?, but ? doesn't work as written. The only thing I've managed to do is add an Ok::<_, ErrorType>(()) after the loop, which is, of course, unreachable (any correctly indicated as such).
No, you can do it for closures, but I don't think the syntax exists for async blocks. You can define an async fn, on which you would have to define the return type?
Thanks. I knew I could define an async fn, but was hoping to avoid it for a simple case like this. I guess I'll have to wait for type ascription or async closures to land for it to be as clean as I'd like.