refactor(lib): update to 2018 edition
This commit is contained in:
		| @@ -2,10 +2,10 @@ use futures::{future, Async, Future, Poll, Stream}; | ||||
| use futures::sync::{mpsc, oneshot}; | ||||
| use want; | ||||
|  | ||||
| use common::Never; | ||||
| use crate::common::Never; | ||||
|  | ||||
| pub type RetryPromise<T, U> = oneshot::Receiver<Result<U, (::Error, Option<T>)>>; | ||||
| pub type Promise<T> = oneshot::Receiver<Result<T, ::Error>>; | ||||
| pub type RetryPromise<T, U> = oneshot::Receiver<Result<U, (crate::Error, Option<T>)>>; | ||||
| pub type Promise<T> = oneshot::Receiver<Result<T, crate::Error>>; | ||||
|  | ||||
| pub fn channel<T, U>() -> (Sender<T, U>, Receiver<T, U>) { | ||||
|     let (tx, rx) = mpsc::unbounded(); | ||||
| @@ -51,9 +51,9 @@ pub struct UnboundedSender<T, U> { | ||||
| } | ||||
|  | ||||
| impl<T, U> Sender<T, U> { | ||||
|     pub fn poll_ready(&mut self) -> Poll<(), ::Error> { | ||||
|     pub fn poll_ready(&mut self) -> Poll<(), crate::Error> { | ||||
|         self.giver.poll_want() | ||||
|             .map_err(|_| ::Error::new_closed()) | ||||
|             .map_err(|_| crate::Error::new_closed()) | ||||
|     } | ||||
|  | ||||
|     pub fn is_ready(&self) -> bool { | ||||
| @@ -167,14 +167,14 @@ struct Envelope<T, U>(Option<(T, Callback<T, U>)>); | ||||
| impl<T, U> Drop for Envelope<T, U> { | ||||
|     fn drop(&mut self) { | ||||
|         if let Some((val, cb)) = self.0.take() { | ||||
|             let _ = cb.send(Err((::Error::new_canceled().with("connection closed"), Some(val)))); | ||||
|             let _ = cb.send(Err((crate::Error::new_canceled().with("connection closed"), Some(val)))); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub enum Callback<T, U> { | ||||
|     Retry(oneshot::Sender<Result<U, (::Error, Option<T>)>>), | ||||
|     NoRetry(oneshot::Sender<Result<U, ::Error>>), | ||||
|     Retry(oneshot::Sender<Result<U, (crate::Error, Option<T>)>>), | ||||
|     NoRetry(oneshot::Sender<Result<U, crate::Error>>), | ||||
| } | ||||
|  | ||||
| impl<T, U> Callback<T, U> { | ||||
| @@ -192,7 +192,7 @@ impl<T, U> Callback<T, U> { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub(crate) fn send(self, val: Result<U, (::Error, Option<T>)>) { | ||||
|     pub(crate) fn send(self, val: Result<U, (crate::Error, Option<T>)>) { | ||||
|         match self { | ||||
|             Callback::Retry(tx) => { | ||||
|                 let _ = tx.send(val); | ||||
| @@ -205,7 +205,7 @@ impl<T, U> Callback<T, U> { | ||||
|  | ||||
|     pub(crate) fn send_when( | ||||
|         self, | ||||
|         mut when: impl Future<Item=U, Error=(::Error, Option<T>)>, | ||||
|         mut when: impl Future<Item=U, Error=(crate::Error, Option<T>)>, | ||||
|     ) -> impl Future<Item=(), Error=()> { | ||||
|         let mut cb = Some(self); | ||||
|  | ||||
| @@ -266,7 +266,7 @@ mod tests { | ||||
|                     .expect_err("promise should error"); | ||||
|  | ||||
|                 match (err.0.kind(), err.1) { | ||||
|                     (&::error::Kind::Canceled, Some(_)) => (), | ||||
|                     (&crate::error::Kind::Canceled, Some(_)) => (), | ||||
|                     e => panic!("expected Error::Cancel(_), found {:?}", e), | ||||
|                 } | ||||
|  | ||||
| @@ -312,7 +312,7 @@ mod tests { | ||||
|     #[cfg(feature = "nightly")] | ||||
|     #[bench] | ||||
|     fn giver_queue_throughput(b: &mut test::Bencher) { | ||||
|         use {Body, Request, Response}; | ||||
|         use crate::{Body, Request, Response}; | ||||
|         let (mut tx, mut rx) = super::channel::<Request<Body>, Response<Body>>(); | ||||
|  | ||||
|         b.iter(move || { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user