mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00

This change removes all references to `Stream` from within the `tokio` crate and moves them into a new `tokio-stream` crate. Most types have had their `impl Stream` removed as well in-favor of their inherent methods. Closes #2870
16 lines
382 B
Rust
16 lines
382 B
Rust
use async_stream::stream;
|
|
use tokio::sync::mpsc::{self, UnboundedSender};
|
|
use tokio_stream::Stream;
|
|
|
|
pub fn unbounded_channel_stream<T: Unpin>() -> (UnboundedSender<T>, impl Stream<Item = T>) {
|
|
let (tx, mut rx) = mpsc::unbounded_channel();
|
|
|
|
let stream = stream! {
|
|
while let Some(item) = rx.recv().await {
|
|
yield item;
|
|
}
|
|
};
|
|
|
|
(tx, stream)
|
|
}
|