summaryrefslogtreecommitdiff
path: root/vendor/async-stream/examples
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-02 18:36:06 -0600
committermo khan <mo@mokhan.ca>2025-07-02 18:36:06 -0600
commit8cdfa445d6629ffef4cb84967ff7017654045bc2 (patch)
tree22f0b0907c024c78d26a731e2e1f5219407d8102 /vendor/async-stream/examples
parent4351c74c7c5f97156bc94d3a8549b9940ac80e3f (diff)
chore: add vendor directory
Diffstat (limited to 'vendor/async-stream/examples')
-rw-r--r--vendor/async-stream/examples/tcp_accept.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/vendor/async-stream/examples/tcp_accept.rs b/vendor/async-stream/examples/tcp_accept.rs
new file mode 100644
index 00000000..1b69bdaf
--- /dev/null
+++ b/vendor/async-stream/examples/tcp_accept.rs
@@ -0,0 +1,21 @@
+use async_stream::stream;
+use futures_util::pin_mut;
+use futures_util::stream::StreamExt;
+use tokio::net::TcpListener;
+
+#[tokio::main]
+async fn main() {
+ let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
+
+ let incoming = stream! {
+ loop {
+ let (socket, _) = listener.accept().await.unwrap();
+ yield socket;
+ }
+ };
+ pin_mut!(incoming);
+
+ while let Some(v) = incoming.next().await {
+ println!("handle = {:?}", v);
+ }
+}