chore: enable full CI run (#1399)

* update all tests
* fix doc examples
* misc API tweaks
This commit is contained in:
Carl Lerche
2019-08-07 20:02:13 -07:00
committed by GitHub
parent 831be9c08e
commit 962521f449
53 changed files with 1231 additions and 2793 deletions
+44 -2
View File
@@ -87,12 +87,54 @@ impl<T> UnboundedReceiver<T> {
UnboundedReceiver { chan }
}
/// TODO: dox
#[doc(hidden)] // TODO: remove
pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
self.chan.recv(cx)
}
/// TODO: Dox
/// Receive the next value for this receiver.
///
/// `None` is returned when all `Sender` halves have dropped, indicating
/// that no further values can be sent on the channel.
///
/// # Examples
///
/// ```
/// #![feature(async_await)]
///
/// use tokio::sync::mpsc;
///
/// #[tokio::main]
/// async fn main() {
/// let (mut tx, mut rx) = mpsc::unbounded_channel();
///
/// tokio::spawn(async move {
/// tx.try_send("hello").unwrap();
/// });
///
/// assert_eq!(Some("hello"), rx.recv().await);
/// assert_eq!(None, rx.recv().await);
/// }
/// ```
///
/// Values are buffered:
///
/// ```
/// #![feature(async_await)]
///
/// use tokio::sync::mpsc;
///
/// #[tokio::main]
/// async fn main() {
/// let (mut tx, mut rx) = mpsc::unbounded_channel();
///
/// tx.try_send("hello").unwrap();
/// tx.try_send("world").unwrap();
///
/// assert_eq!(Some("hello"), rx.recv().await);
/// assert_eq!(Some("world"), rx.recv().await);
/// }
/// ```
#[allow(clippy::needless_lifetimes)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3988
pub async fn recv(&mut self) -> Option<T> {
use futures_util::future::poll_fn;