summaryrefslogtreecommitdiffstats
path: root/tokio/tests/stream_pending.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-01-11 12:32:19 -0800
committerGitHub <noreply@github.com>2020-01-11 12:32:19 -0800
commit8471e0a0ee7f6c973fb517ccb7efcf6c7e2ddc6f (patch)
tree16e9793243fdccfe4276a19ad4f3d536e9830c7a /tokio/tests/stream_pending.rs
parent0ba6e9abdbe1b42997d183adf5a39488c9543200 (diff)
stream: add `empty()` and `pending()` (#2092)
`stream::empty()` is the asynchronous equivalent to `std::iter::empty()`. `pending()` provides a stream that never becomes ready.
Diffstat (limited to 'tokio/tests/stream_pending.rs')
-rw-r--r--tokio/tests/stream_pending.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tokio/tests/stream_pending.rs b/tokio/tests/stream_pending.rs
new file mode 100644
index 00000000..f4d3080d
--- /dev/null
+++ b/tokio/tests/stream_pending.rs
@@ -0,0 +1,14 @@
+use tokio::stream::{self, Stream, StreamExt};
+use tokio_test::{assert_pending, task};
+
+#[tokio::test]
+async fn basic_usage() {
+ let mut stream = stream::pending::<i32>();
+
+ for _ in 0..2 {
+ assert_eq!(stream.size_hint(), (0, None));
+
+ let mut next = task::spawn(async { stream.next().await });
+ assert_pending!(next.poll());
+ }
+}