summaryrefslogtreecommitdiff
path: root/vendor/async-stream/src/next.rs
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/src/next.rs
parent4351c74c7c5f97156bc94d3a8549b9940ac80e3f (diff)
chore: add vendor directory
Diffstat (limited to 'vendor/async-stream/src/next.rs')
-rw-r--r--vendor/async-stream/src/next.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/async-stream/src/next.rs b/vendor/async-stream/src/next.rs
new file mode 100644
index 00000000..7b1e0467
--- /dev/null
+++ b/vendor/async-stream/src/next.rs
@@ -0,0 +1,32 @@
+use futures_core::Stream;
+use std::future::Future;
+use std::pin::Pin;
+use std::task::{Context, Poll};
+
+// This is equivalent to the `futures::StreamExt::next` method.
+// But we want to make this crate dependency as small as possible, so we define our `next` function.
+#[doc(hidden)]
+pub fn next<S>(stream: &mut S) -> impl Future<Output = Option<S::Item>> + '_
+where
+ S: Stream + Unpin,
+{
+ Next { stream }
+}
+
+#[derive(Debug)]
+struct Next<'a, S> {
+ stream: &'a mut S,
+}
+
+impl<S> Unpin for Next<'_, S> where S: Unpin {}
+
+impl<S> Future for Next<'_, S>
+where
+ S: Stream + Unpin,
+{
+ type Output = Option<S::Item>;
+
+ fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+ Pin::new(&mut self.stream).poll_next(cx)
+ }
+}