Update Tokio to Rust 2018 (#1082)

This commit is contained in:
Carl Lerche
2019-05-14 10:27:36 -07:00
committed by GitHub
parent 79d8820050
commit cb4aea394e
343 changed files with 1725 additions and 2813 deletions
+8 -15
View File
@@ -18,9 +18,6 @@
//! # Examples
//!
//! ```
//! # extern crate futures;
//! extern crate tokio;
//!
//! use tokio::prelude::*;
//! use tokio::sync::watch;
//!
@@ -58,8 +55,7 @@
use fnv::FnvHashMap;
use futures::task::AtomicTask;
use futures::{Async, AsyncSink, Poll, Sink, StartSend, Stream};
use futures::{try_ready, Async, AsyncSink, Poll, Sink, StartSend, Stream};
use std::ops;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
@@ -97,7 +93,7 @@ pub struct Sender<T> {
/// long lived borrows could cause the produce half to block. It is recommended
/// to keep the borrow as short lived as possible.
#[derive(Debug)]
pub struct Ref<'a, T: 'a> {
pub struct Ref<'a, T> {
inner: RwLockReadGuard<'a, T>,
}
@@ -121,7 +117,7 @@ pub mod error {
// ===== impl RecvError =====
impl fmt::Display for RecvError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use std::error::Error;
write!(fmt, "{}", self.description())
}
@@ -136,7 +132,7 @@ pub mod error {
// ===== impl SendError =====
impl<T: fmt::Debug> fmt::Display for SendError<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use std::error::Error;
write!(fmt, "{}", self.description())
}
@@ -189,9 +185,6 @@ const CLOSED: usize = 1;
/// # Examples
///
/// ```
/// # extern crate futures;
/// extern crate tokio;
///
/// use tokio::prelude::*;
/// use tokio::sync::watch;
///
@@ -250,12 +243,12 @@ impl<T> Receiver<T> {
/// # Examples
///
/// ```
/// # extern crate tokio;
/// # use tokio::sync::watch;
/// use tokio::sync::watch;
///
/// let (_, rx) = watch::channel("hello");
/// assert_eq!(*rx.get_ref(), "hello");
/// ```
pub fn get_ref(&self) -> Ref<T> {
pub fn get_ref(&self) -> Ref<'_, T> {
let inner = self.shared.value.read().unwrap();
Ref { inner }
}
@@ -268,7 +261,7 @@ impl<T> Receiver<T> {
///
/// Only the **most recent** value is returned. If the receiver is falling
/// behind the sender, intermediate values are dropped.
pub fn poll_ref(&mut self) -> Poll<Option<Ref<T>>, error::RecvError> {
pub fn poll_ref(&mut self) -> Poll<Option<Ref<'_, T>>, error::RecvError> {
// Make sure the task is up to date
self.inner.task.register();