Skip to content

Add async_try_stream to support ? operator in async stream #15

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

Merged
merged 1 commit into from
Sep 6, 2019

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Aug 21, 2019

? operator can be used with the #[async_try_stream] attribute and async_try_stream_block! macro.

#![feature(generators)]
use futures::stream::Stream;
use futures_async_stream::try_async_stream;

#[async_try_stream(ok = i32, error = Box<dyn std::error::Error + Send + Sync + 'static>)]
async fn foo(stream: impl Stream<Item = String>) {
    #[for_await]
    for x in stream {
        yield x.parse()?;
    }
}

Closes #2

@taiki-e taiki-e marked this pull request as ready for review August 21, 2019 19:03
@taiki-e taiki-e force-pushed the async-try-stream branch 6 times, most recently from 22051d6 to 101c93a Compare September 6, 2019 14:46
@taiki-e
Copy link
Owner Author

taiki-e commented Sep 6, 2019

bors r+

bors bot added a commit that referenced this pull request Sep 6, 2019
15: Add async_try_stream to support ? operator in async stream r=taiki-e a=taiki-e

`?` operator can be used with the `#[async_try_stream]` attribute and `async_try_stream_block!` macro.

```rust
#![feature(generators)]
use futures::stream::Stream;
use futures_async_stream::try_async_stream;

#[async_try_stream(ok = i32, error = Box<dyn std::error::Error + Send + Sync + 'static>)]
async fn foo(stream: impl Stream<Item = String>) {
    #[for_await]
    for x in stream {
        yield x.parse()?;
    }
}
```

Closes #2 

Co-authored-by: Taiki Endo <te316e89@gmail.com>
@bors
Copy link
Contributor

bors bot commented Sep 6, 2019

Build succeeded

  • taiki-e.futures-async-stream

@bors bors bot merged commit d69699d into master Sep 6, 2019
@taiki-e taiki-e deleted the async-try-stream branch September 6, 2019 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ? operator in async stream (add async_try_stream)
2 participants