forked from rust-lang/futures-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Rename
future::empty
to pending
and add stream:Lpending
Fixes the inconsistency between `future::empty` and `stream::empty`. I went with `pending` over `never` since there are already a future called `Never` in the library. Closes rust-lang#1624
- Loading branch information
Markus Westerlind
committed
Jun 27, 2019
1 parent
d9ced4e
commit 2e1aca4
Showing
9 changed files
with
83 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use core::marker; | ||
use core::pin::Pin; | ||
|
||
use futures_core::{Stream, Poll}; | ||
use futures_core::task; | ||
|
||
/// A stream which never returns any elements. | ||
/// | ||
/// This stream can be created with the `stream::pending` function. | ||
#[derive(Debug)] | ||
#[must_use = "streams do nothing unless polled"] | ||
pub struct Pending<T> { | ||
_data: marker::PhantomData<T>, | ||
} | ||
|
||
/// Creates a stream which never returns any elements. | ||
/// | ||
/// The returned stream will always return `Pending` when polled. | ||
pub fn pending<T>() -> Pending<T> { | ||
Pending { _data: marker::PhantomData } | ||
} | ||
|
||
impl<T> Stream for Pending<T> { | ||
type Item = T; | ||
|
||
fn poll_next(self: Pin<&mut Self>, _: &mut task::Context<'_>) -> Poll<Option<Self::Item>> { | ||
Poll::Pending | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters