-
Notifications
You must be signed in to change notification settings - Fork 33
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
Can't use ? if try_stream! wraps select! #63
Comments
I'm able to easily work around this by using stream! rather than try_stream. So far it looks like I can still get my job done just without the niceness of ? |
This seems due to that visit_token_stream_impl only visits async-stream/async-stream-impl/src/lib.rs Lines 45 to 94 in 8bf33a6
|
Just bumped into this. I'm using latest v0.3.5. |
I've also just run into this issue on version This compiles fine: use async_stream::try_stream;
use futures::Stream;
async fn add(x: u8) -> Result<u8, String> {
Ok(x + 1)
}
fn foo() -> impl Stream<Item = Result<u8, String>> {
try_stream! {
loop {
tokio::select! {
a = add(1) => { a },
b = add(2) => { b },
}?; // ? used here outside the `select!` macro
yield 1;
}
}
} whereas moving the fn foo() -> impl Stream<Item = Result<u8, String>> {
try_stream! {
loop {
tokio::select! {
a = add(1) => { a? },
b = add(2) => { b? },
};
yield 1;
}
}
} results in an error similar to the one in the original description. While it's possible to work around it by following the first pattern, it can become quite messy in a non-trivial situation. |
I have multiple streams I am joining in a select along with a timeout future that caused me to run into this. I tried to boil it down to a minimal code sample that can trigger the problem. It as follows:
This fails with the error:
And I confirmed I'm on 0.3.2 so I have the fix for #27
The text was updated successfully, but these errors were encountered: