Skip to content

Commit 62eda1e

Browse files
committed
Add AsyncSync::{is_not_ready, is_ready}
Closes rust-lang#236
1 parent 05c39f7 commit 62eda1e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/poll.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ pub enum AsyncSink<T> {
7474
NotReady(T),
7575
}
7676

77+
impl<T> AsyncSink<T> {
78+
/// Returns whether this is `AsyncSink::NotReady`
79+
pub fn is_not_ready(&self) -> bool {
80+
match *self {
81+
AsyncSink::NotReady(_) => true,
82+
AsyncSink::Ready => false,
83+
}
84+
}
85+
86+
/// Returns whether this is `AsyncSink::Ready`
87+
pub fn is_ready(&self) -> bool {
88+
!self.is_not_ready()
89+
}
90+
}
91+
92+
7793
/// Return type of the `Sink::start_send` method, indicating the outcome of a
7894
/// send attempt. See `AsyncSink` for more details.
7995
pub type StartSend<T, E> = Result<AsyncSink<T>, E>;

0 commit comments

Comments
 (0)