Coverage Report

Created: 2025-09-27 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/futures-util-0.3.31/src/stream/pending.rs
Line
Count
Source
1
use super::assert_stream;
2
use core::marker;
3
use core::pin::Pin;
4
use futures_core::stream::{FusedStream, Stream};
5
use futures_core::task::{Context, Poll};
6
7
/// Stream for the [`pending()`] function.
8
#[derive(Debug)]
9
#[must_use = "streams do nothing unless polled"]
10
pub struct Pending<T> {
11
    _data: marker::PhantomData<T>,
12
}
13
14
/// Creates a stream which never returns any elements.
15
///
16
/// The returned stream will always return `Pending` when polled.
17
0
pub fn pending<T>() -> Pending<T> {
18
0
    assert_stream::<T, _>(Pending { _data: marker::PhantomData })
19
0
}
20
21
impl<T> Unpin for Pending<T> {}
22
23
impl<T> FusedStream for Pending<T> {
24
0
    fn is_terminated(&self) -> bool {
25
0
        true
26
0
    }
27
}
28
29
impl<T> Stream for Pending<T> {
30
    type Item = T;
31
32
0
    fn poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<Self::Item>> {
33
0
        Poll::Pending
34
0
    }
35
36
0
    fn size_hint(&self) -> (usize, Option<usize>) {
37
0
        (0, Some(0))
38
0
    }
39
}
40
41
impl<T> Clone for Pending<T> {
42
0
    fn clone(&self) -> Self {
43
0
        pending()
44
0
    }
45
}