forked from rust-lang/rfcs
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This might be better maybe dunno hopefully
- Loading branch information
1 parent
b32bf86
commit 8c99319
Showing
3 changed files
with
35 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use core::marker; | ||
|
||
use stream::Stream; | ||
use Poll; | ||
|
||
/// A stream which is never resolved. | ||
/// | ||
/// This stream can be created with the `stream::empty` function. | ||
pub struct Empty<T, E> { | ||
_data: marker::PhantomData<(T, E)>, | ||
} | ||
|
||
/// Creates a stream which never resolves, representing a computation that never | ||
/// finishes. | ||
/// | ||
/// The returned stream will never resolve with a value but is still | ||
/// susceptible to cancellation. That is, if a callback is scheduled on the | ||
/// returned stream, it is only run once the stream is dropped (canceled). | ||
pub fn empty<T, E>() -> Empty<T, E> { | ||
Empty { _data: marker::PhantomData } | ||
} | ||
|
||
impl<T, E> Stream for Empty<T, E> | ||
where T: Send + 'static, | ||
E: Send + 'static | ||
{ | ||
type Item = T; | ||
type Error = E; | ||
|
||
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { | ||
Poll::Ok(None) | ||
} | ||
} |
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