Skip to content
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

Method for creating a stream from a future #52

Closed
avitex opened this issue Mar 6, 2022 · 1 comment · Fixed by #59
Closed

Method for creating a stream from a future #52

avitex opened this issue Mar 6, 2022 · 1 comment · Fixed by #59

Comments

@avitex
Copy link

avitex commented Mar 6, 2022

In futures there is stream::once which allows creating a stream from a future. I would argue it generic enough and simple enough to warrant it being functionality provided in this library.

Would a stream::future or similar named function be accepted with a PR?

@notgull
Copy link
Member

notgull commented May 28, 2022

Technically, you can do:

use futures_lite::stream::{once, StreamExt};
let my_fut = async { /* ... */ };
let stream = once(()).then(move |()| my_fut);

But this seems like an antipattern. I like this idea, although I'd rather see it as a combinator on the Future type, like into_stream()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants