This is my first time using this library, and I'm currently facing this issue. The following code fails to compile:
use async_stream::try_stream;
use futures_core::Stream;
fn test() -> impl Stream<Item = Result<u32, ()>> {
try_stream! {
yield Err(())?;
}
}
With the compiler showing this error:
|
5 | / try_stream! {
6 | | yield Err(())?;
| | ^ cannot use the `?` operator in an async block that returns `()`
7 | | }
| |_____- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Result<Infallible, ()>>` is not implemented for `()`
While this code works:
use async_stream::try_stream;
use futures_core::Stream;
fn test() -> impl Stream<Item = Result<u32, ()>> {
try_stream! {
let temp = Err(())?;
yield temp;
}
}
This is my first time using this library, and I'm currently facing this issue. The following code fails to compile:
With the compiler showing this error:
While this code works: