cargo fmt (#604)

Run rustfmt and setup CI to check for it.
This commit is contained in:
danieleades
2019-08-29 17:52:39 +01:00
committed by Sean McArthur
parent 81e0f1ff2a
commit cf8944a0f0
41 changed files with 1399 additions and 1378 deletions

View File

@@ -2,8 +2,8 @@ use std::sync::Arc;
use std::thread;
use std::time::{Duration, Instant};
use futures::{Async, Future, Poll, Stream};
use futures::executor::{self, Notify};
use futures::{Async, Future, Poll, Stream};
use tokio_executor::{enter, EnterError};
pub(crate) fn timeout<F>(fut: F, timeout: Option<Duration>) -> Result<F::Item, Waited<F::Error>>
@@ -11,13 +11,13 @@ where
F: Future,
{
let mut spawn = executor::spawn(fut);
block_on(timeout, |notify| {
spawn.poll_future_notify(notify, 0)
})
block_on(timeout, |notify| spawn.poll_future_notify(notify, 0))
}
pub(crate) fn stream<S>(stream: S, timeout: Option<Duration>) -> WaitStream<S>
where S: Stream {
where
S: Stream,
{
WaitStream {
stream: executor::spawn(stream),
timeout,
@@ -43,7 +43,9 @@ pub(crate) struct WaitStream<S> {
}
impl<S> Iterator for WaitStream<S>
where S: Stream {
where
S: Stream,
{
type Item = Result<S::Item, Waited<S::Error>>;
fn next(&mut self) -> Option<Self::Item> {
@@ -74,9 +76,7 @@ where
F: FnMut(&Arc<ThreadNotify>) -> Poll<U, E>,
{
let _entered = enter().map_err(Waited::Executor)?;
let deadline = timeout.map(|d| {
Instant::now() + d
});
let deadline = timeout.map(|d| Instant::now() + d);
let notify = Arc::new(ThreadNotify {
thread: thread::current(),
});
@@ -99,5 +99,3 @@ where
}
}
}