mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-23 21:51:06 +01:00
Fix code style (#65)
* Fix clippy warnings * cargo fmt * Remove redundant lifetime
This commit is contained in:
parent
13049b80ca
commit
be7904fd57
@ -236,9 +236,9 @@ where
|
||||
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let len = self.buffer.len();
|
||||
if len >= self.high_watermark {
|
||||
return Poll::Pending;
|
||||
Poll::Pending
|
||||
} else {
|
||||
return Poll::Ready(Ok(()));
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ impl Arbiter {
|
||||
// register arbiter
|
||||
let _ = System::current()
|
||||
.sys()
|
||||
.unbounded_send(SystemCommand::RegisterArbiter(id, arb.clone()));
|
||||
.unbounded_send(SystemCommand::RegisterArbiter(id, arb));
|
||||
|
||||
// run loop
|
||||
let _ = match rt.block_on(stop_rx) {
|
||||
|
@ -229,12 +229,12 @@ impl SystemRunner {
|
||||
where
|
||||
F: Future<Output = O>,
|
||||
{
|
||||
let _ = self.rt.block_on(async {
|
||||
self.rt.block_on(async {
|
||||
Arbiter::run_system();
|
||||
});
|
||||
|
||||
let res = self.rt.block_on(fut);
|
||||
let _ = self.rt.block_on(async {
|
||||
self.rt.block_on(async {
|
||||
Arbiter::stop_system();
|
||||
});
|
||||
|
||||
|
@ -125,8 +125,7 @@ impl Runtime {
|
||||
{
|
||||
self.enter(|executor| {
|
||||
// Run the provided future
|
||||
let ret = executor.block_on(f);
|
||||
ret
|
||||
executor.block_on(f)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ impl Accept {
|
||||
delay(Instant::now() + Duration::from_millis(510)).await;
|
||||
let _ = r.set_readiness(mio::Ready::readable());
|
||||
}
|
||||
.boxed(),
|
||||
.boxed(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ impl ServerBuilder {
|
||||
async move {
|
||||
Worker::start(rx1, rx2, services, avail, timeout);
|
||||
}
|
||||
.boxed(),
|
||||
.boxed(),
|
||||
);
|
||||
|
||||
worker
|
||||
@ -401,7 +401,7 @@ impl ServerBuilder {
|
||||
.await;
|
||||
System::current().stop();
|
||||
}
|
||||
.boxed(),
|
||||
.boxed(),
|
||||
);
|
||||
}
|
||||
ready(())
|
||||
|
@ -139,7 +139,7 @@ impl InternalServiceFactory for ConfiguredService {
|
||||
}
|
||||
return Ok(res);
|
||||
}
|
||||
.boxed_local()
|
||||
.boxed_local()
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,6 +266,6 @@ where
|
||||
}
|
||||
};
|
||||
}
|
||||
.boxed_local()
|
||||
.boxed_local()
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ where
|
||||
let _ = f.await;
|
||||
drop(guard);
|
||||
}
|
||||
.boxed_local(),
|
||||
.boxed_local(),
|
||||
);
|
||||
ok(())
|
||||
} else {
|
||||
|
@ -92,7 +92,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin + 'static, P> Service for OpensslAcceptor
|
||||
let acc = acc;
|
||||
tokio_openssl::accept(&acc, io).await
|
||||
}
|
||||
.boxed_local::<'static>(),
|
||||
.boxed_local(),
|
||||
params: Some(params),
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ impl Worker {
|
||||
}
|
||||
wrk.await
|
||||
}
|
||||
.boxed_local(),
|
||||
.boxed_local(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ where
|
||||
}
|
||||
TransportState::Error(err) => {
|
||||
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))
|
||||
} else {
|
||||
*state = TransportState::Error(err);
|
||||
|
@ -133,8 +133,7 @@ impl<T> Receiver<T> {
|
||||
let items = match self.state {
|
||||
State::Open(ref state) => {
|
||||
let mut state = state.borrow_mut();
|
||||
let items = mem::replace(&mut state.buffer, VecDeque::new());
|
||||
items
|
||||
mem::replace(&mut state.buffer, VecDeque::new())
|
||||
}
|
||||
State::Closed(_) => return,
|
||||
};
|
||||
|
@ -135,7 +135,7 @@ impl<T> Sender<T> {
|
||||
/// non-futures related thread, though, which would otherwise panic if
|
||||
/// `poll_cancel` were called.
|
||||
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);
|
||||
}
|
||||
State::Closed(_) => return,
|
||||
State::Closed(_) => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -180,7 +180,7 @@ impl<T> Future for Receiver<T> {
|
||||
let inner = match this.state {
|
||||
State::Open(ref mut inner) => inner,
|
||||
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)),
|
||||
},
|
||||
};
|
||||
|
@ -89,9 +89,9 @@ impl ResourceDef {
|
||||
.collect();
|
||||
PatternType::Dynamic(re, names, len)
|
||||
} else if for_prefix {
|
||||
PatternType::Prefix(pattern.clone())
|
||||
PatternType::Prefix(pattern)
|
||||
} else {
|
||||
PatternType::Static(pattern.clone())
|
||||
PatternType::Static(pattern)
|
||||
};
|
||||
|
||||
ResourceDef {
|
||||
@ -99,7 +99,7 @@ impl ResourceDef {
|
||||
elements,
|
||||
id: 0,
|
||||
name: String::new(),
|
||||
pattern: path.to_owned(),
|
||||
pattern: path,
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,7 +234,8 @@ impl ResourceDef {
|
||||
} else {
|
||||
return false;
|
||||
};
|
||||
path.skip(min(rpath.len(), len) as u16);
|
||||
let rpath_len = rpath.len();
|
||||
path.skip(min(rpath_len, len) as u16);
|
||||
true
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user