smol-rs / futures-lite

Futures, streams, and async I/O combinators.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Method for creating a stream from a future

avitex opened this issue · comments

commented

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?

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()?