-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
Description
according to this article
Using ? with different Error type in the same async block seems unachievable
async fn a() -> Result<(), reqwest::Error> {Ok(())}
async fn b() -> Result<(), std::io::Error> {Ok(())}
fn c() {
async {
a().await?;
b().await?;
Ok(()) // error msg 1
// Ok::<(), impl std::error::Error>(()) // error msg 2
};
}
async fn d() -> Result<(), impl std::error::Error> {
a().await?;
b().await?;
Ok(())
}1
--> src/x.rs:6:9
|
6 | a().await?;
| ^^^^^^^^^^ cannot infer type
2
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> src/x.rs:8:18
|
8 | Ok::<(), impl std::error::Error>(())
|
Maybe add something like this? Unify closure and block
async || -> Result<(), impl std::error::Error> {
a().await?;
b().await?;
Ok(())
};Metadata
Metadata
Assignees
Labels
No labels