1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 00:01:11 +01:00

Fix code style (#65)

* Fix clippy warnings

* cargo fmt

* Remove redundant lifetime
This commit is contained in:
Yuki Okushi 2019-11-15 00:28:29 +09:00 committed by GitHub
parent 13049b80ca
commit be7904fd57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 24 additions and 25 deletions

View File

@ -236,9 +236,9 @@ where
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
let len = self.buffer.len(); let len = self.buffer.len();
if len >= self.high_watermark { if len >= self.high_watermark {
return Poll::Pending; Poll::Pending
} else { } else {
return Poll::Ready(Ok(())); Poll::Ready(Ok(()))
} }
} }

View File

@ -120,7 +120,7 @@ impl Arbiter {
// register arbiter // register arbiter
let _ = System::current() let _ = System::current()
.sys() .sys()
.unbounded_send(SystemCommand::RegisterArbiter(id, arb.clone())); .unbounded_send(SystemCommand::RegisterArbiter(id, arb));
// run loop // run loop
let _ = match rt.block_on(stop_rx) { let _ = match rt.block_on(stop_rx) {

View File

@ -229,12 +229,12 @@ impl SystemRunner {
where where
F: Future<Output = O>, F: Future<Output = O>,
{ {
let _ = self.rt.block_on(async { self.rt.block_on(async {
Arbiter::run_system(); Arbiter::run_system();
}); });
let res = self.rt.block_on(fut); let res = self.rt.block_on(fut);
let _ = self.rt.block_on(async { self.rt.block_on(async {
Arbiter::stop_system(); Arbiter::stop_system();
}); });

View File

@ -125,8 +125,7 @@ impl Runtime {
{ {
self.enter(|executor| { self.enter(|executor| {
// Run the provided future // Run the provided future
let ret = executor.block_on(f); executor.block_on(f)
ret
}) })
} }

View File

@ -445,7 +445,7 @@ impl Accept {
delay(Instant::now() + Duration::from_millis(510)).await; delay(Instant::now() + Duration::from_millis(510)).await;
let _ = r.set_readiness(mio::Ready::readable()); let _ = r.set_readiness(mio::Ready::readable());
} }
.boxed(), .boxed(),
); );
return; return;
} }

View File

@ -326,7 +326,7 @@ impl ServerBuilder {
async move { async move {
Worker::start(rx1, rx2, services, avail, timeout); Worker::start(rx1, rx2, services, avail, timeout);
} }
.boxed(), .boxed(),
); );
worker worker
@ -401,7 +401,7 @@ impl ServerBuilder {
.await; .await;
System::current().stop(); System::current().stop();
} }
.boxed(), .boxed(),
); );
} }
ready(()) ready(())

View File

@ -139,7 +139,7 @@ impl InternalServiceFactory for ConfiguredService {
} }
return Ok(res); return Ok(res);
} }
.boxed_local() .boxed_local()
} }
} }
@ -266,6 +266,6 @@ where
} }
}; };
} }
.boxed_local() .boxed_local()
} }
} }

View File

@ -87,7 +87,7 @@ where
let _ = f.await; let _ = f.await;
drop(guard); drop(guard);
} }
.boxed_local(), .boxed_local(),
); );
ok(()) ok(())
} else { } else {

View File

@ -92,7 +92,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin + 'static, P> Service for OpensslAcceptor
let acc = acc; let acc = acc;
tokio_openssl::accept(&acc, io).await tokio_openssl::accept(&acc, io).await
} }
.boxed_local::<'static>(), .boxed_local(),
params: Some(params), params: Some(params),
} }
} }

View File

@ -187,7 +187,7 @@ impl Worker {
} }
wrk.await wrk.await
} }
.boxed_local(), .boxed_local(),
); );
} }

View File

@ -221,7 +221,7 @@ where
} }
TransportState::Error(err) => { TransportState::Error(err) => {
let is_empty = framed.is_write_buf_empty(); let is_empty = framed.is_write_buf_empty();
if is_empty || (poll_write(cx, state, framed, rx, inner) || is_empty) { if is_empty || poll_write(cx, state, framed, rx, inner) {
Poll::Ready(Err(err)) Poll::Ready(Err(err))
} else { } else {
*state = TransportState::Error(err); *state = TransportState::Error(err);

View File

@ -133,8 +133,7 @@ impl<T> Receiver<T> {
let items = match self.state { let items = match self.state {
State::Open(ref state) => { State::Open(ref state) => {
let mut state = state.borrow_mut(); let mut state = state.borrow_mut();
let items = mem::replace(&mut state.buffer, VecDeque::new()); mem::replace(&mut state.buffer, VecDeque::new())
items
} }
State::Closed(_) => return, State::Closed(_) => return,
}; };

View File

@ -135,7 +135,7 @@ impl<T> Sender<T> {
/// non-futures related thread, though, which would otherwise panic if /// non-futures related thread, though, which would otherwise panic if
/// `poll_cancel` were called. /// `poll_cancel` were called.
pub fn is_canceled(&self) -> bool { pub fn is_canceled(&self) -> bool {
!self.inner.upgrade().is_some() self.inner.upgrade().is_none()
} }
} }
@ -166,7 +166,7 @@ impl<T> Receiver<T> {
self.state = State::Closed(value); self.state = State::Closed(value);
} }
State::Closed(_) => return, State::Closed(_) => {}
}; };
} }
} }
@ -180,7 +180,7 @@ impl<T> Future for Receiver<T> {
let inner = match this.state { let inner = match this.state {
State::Open(ref mut inner) => inner, State::Open(ref mut inner) => inner,
State::Closed(ref mut item) => match item.take() { State::Closed(ref mut item) => match item.take() {
Some(item) => return Poll::Ready(Ok(item.into())), Some(item) => return Poll::Ready(Ok(item)),
None => return Poll::Ready(Err(Canceled)), None => return Poll::Ready(Err(Canceled)),
}, },
}; };

View File

@ -89,9 +89,9 @@ impl ResourceDef {
.collect(); .collect();
PatternType::Dynamic(re, names, len) PatternType::Dynamic(re, names, len)
} else if for_prefix { } else if for_prefix {
PatternType::Prefix(pattern.clone()) PatternType::Prefix(pattern)
} else { } else {
PatternType::Static(pattern.clone()) PatternType::Static(pattern)
}; };
ResourceDef { ResourceDef {
@ -99,7 +99,7 @@ impl ResourceDef {
elements, elements,
id: 0, id: 0,
name: String::new(), name: String::new(),
pattern: path.to_owned(), pattern: path,
} }
} }
@ -234,7 +234,8 @@ impl ResourceDef {
} else { } else {
return false; return false;
}; };
path.skip(min(rpath.len(), len) as u16); let rpath_len = rpath.len();
path.skip(min(rpath_len, len) as u16);
true true
} }
} }