mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-24 02:21:07 +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>> {
|
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(()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -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,
|
||||||
};
|
};
|
||||||
|
@ -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)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user