googleapis / googleapis/google-cloud-rust

Consider offering `try_next() -> Result<Option<T>>` for our stream-like things

Open
#5,671 0 comments 0 reactions 0 assignees View on GitHub
type: feature request
Dominant language
Rust
Stars
955
Forks
144
Avg merge
1d 5h
Merged PRs (30d)
279

Description

Our stream-like things all have a `next()` (or maybe `poll()`) method which return an `Option>`.

So often example code looks like:

```rs
let mut stream = ...;
while let Some(item) = stream.next().await.transpose()? {
println!("item={item:?}");
}
```

To slightly improve application ergonomics, we could consider offering a `try_next()` for our streams as a shorthand for omitting the `transpose()` (akin to `futures::TryStreamExt`)

```rs
let mut stream = ...;
while let Some(item) = stream.try_next().await? {
println!("item={item:?}");
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.