mirror of https://github.com/fafhrd91/actix-web
chore: address clippy lints
This commit is contained in:
parent
cbf5e948db
commit
5de1c9de75
|
@ -66,6 +66,7 @@ type PathFilter = dyn Fn(&Path, &RequestHead) -> bool;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{
|
use std::{
|
||||||
|
fmt::Write as _,
|
||||||
fs::{self},
|
fs::{self},
|
||||||
ops::Add,
|
ops::Add,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
|
@ -848,8 +849,10 @@ mod tests {
|
||||||
let filename_encoded = filename
|
let filename_encoded = filename
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| format!("%{:02X}", c))
|
.fold(String::new(), |mut buf, c| {
|
||||||
.collect::<String>();
|
write!(&mut buf, "%{:02X}", c).unwrap();
|
||||||
|
buf
|
||||||
|
});
|
||||||
std::fs::File::create(tmpdir.path().join(filename)).unwrap();
|
std::fs::File::create(tmpdir.path().join(filename)).unwrap();
|
||||||
|
|
||||||
let srv = test::init_service(App::new().service(Files::new("", tmpdir.path()))).await;
|
let srv = test::init_service(App::new().service(Files::new("", tmpdir.path()))).await;
|
||||||
|
|
|
@ -117,6 +117,7 @@ impl PayloadSender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::needless_pass_by_ref_mut)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn need_read(&self, cx: &mut Context<'_>) -> PayloadStatus {
|
pub fn need_read(&self, cx: &mut Context<'_>) -> PayloadStatus {
|
||||||
// we check need_read only if Payload (other side) is alive,
|
// we check need_read only if Payload (other side) is alive,
|
||||||
|
@ -174,7 +175,7 @@ impl Inner {
|
||||||
|
|
||||||
/// Register future waiting data from payload.
|
/// Register future waiting data from payload.
|
||||||
/// Waker would be used in `Inner::wake`
|
/// Waker would be used in `Inner::wake`
|
||||||
fn register(&mut self, cx: &mut Context<'_>) {
|
fn register(&mut self, cx: &Context<'_>) {
|
||||||
if self
|
if self
|
||||||
.task
|
.task
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -186,7 +187,7 @@ impl Inner {
|
||||||
|
|
||||||
// Register future feeding data to payload.
|
// Register future feeding data to payload.
|
||||||
/// Waker would be used in `Inner::wake_io`
|
/// Waker would be used in `Inner::wake_io`
|
||||||
fn register_io(&mut self, cx: &mut Context<'_>) {
|
fn register_io(&mut self, cx: &Context<'_>) {
|
||||||
if self
|
if self
|
||||||
.io_task
|
.io_task
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -221,7 +222,7 @@ impl Inner {
|
||||||
|
|
||||||
fn poll_next(
|
fn poll_next(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
cx: &mut Context<'_>,
|
cx: &Context<'_>,
|
||||||
) -> Poll<Option<Result<Bytes, PayloadError>>> {
|
) -> Poll<Option<Result<Bytes, PayloadError>>> {
|
||||||
if let Some(data) = self.items.pop_front() {
|
if let Some(data) = self.items.pop_front() {
|
||||||
self.len -= data.len();
|
self.len -= data.len();
|
||||||
|
|
|
@ -252,7 +252,7 @@ impl InnerMultipart {
|
||||||
fn poll(
|
fn poll(
|
||||||
&mut self,
|
&mut self,
|
||||||
safety: &Safety,
|
safety: &Safety,
|
||||||
cx: &mut Context<'_>,
|
cx: &Context<'_>,
|
||||||
) -> Poll<Option<Result<Field, MultipartError>>> {
|
) -> Poll<Option<Result<Field, MultipartError>>> {
|
||||||
if self.state == InnerState::Eof {
|
if self.state == InnerState::Eof {
|
||||||
Poll::Ready(None)
|
Poll::Ready(None)
|
||||||
|
@ -740,7 +740,7 @@ impl Safety {
|
||||||
self.clean.get()
|
self.clean.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone(&self, cx: &mut Context<'_>) -> Safety {
|
fn clone(&self, cx: &Context<'_>) -> Safety {
|
||||||
let payload = Rc::clone(&self.payload);
|
let payload = Rc::clone(&self.payload);
|
||||||
let s = Safety {
|
let s = Safety {
|
||||||
task: LocalWaker::new(),
|
task: LocalWaker::new(),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(clippy::uninlined_format_args)]
|
#![allow(clippy::uninlined_format_args)]
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::{borrow::Cow, fmt::Write as _};
|
||||||
|
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
@ -8,9 +8,10 @@ fn compare_quoters(c: &mut Criterion) {
|
||||||
let mut group = c.benchmark_group("Compare Quoters");
|
let mut group = c.benchmark_group("Compare Quoters");
|
||||||
|
|
||||||
let quoter = actix_router::Quoter::new(b"", b"");
|
let quoter = actix_router::Quoter::new(b"", b"");
|
||||||
let path_quoted = (0..=0x7f)
|
let path_quoted = (0..=0x7f).fold(String::new(), |mut buf, c| {
|
||||||
.map(|c| format!("%{:02X}", c))
|
write!(&mut buf, "%{:02X}", c).unwrap();
|
||||||
.collect::<String>();
|
buf
|
||||||
|
});
|
||||||
let path_unquoted = ('\u{00}'..='\u{7f}').collect::<String>();
|
let path_unquoted = ('\u{00}'..='\u{7f}').collect::<String>();
|
||||||
|
|
||||||
group.bench_function("quoter_unquoted", |b| {
|
group.bench_function("quoter_unquoted", |b| {
|
||||||
|
|
|
@ -62,6 +62,8 @@ impl ResourcePath for Url {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::fmt::Write as _;
|
||||||
|
|
||||||
use http::Uri;
|
use http::Uri;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -78,7 +80,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn percent_encode(data: &[u8]) -> String {
|
fn percent_encode(data: &[u8]) -> String {
|
||||||
data.iter().map(|c| format!("%{:02X}", c)).collect()
|
data.iter()
|
||||||
|
.fold(String::with_capacity(data.len() * 3), |mut buf, c| {
|
||||||
|
write!(&mut buf, "%{:02X}", c).unwrap();
|
||||||
|
buf
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -112,11 +112,7 @@ where
|
||||||
let endpoint_fut = self.endpoint.new_service(());
|
let endpoint_fut = self.endpoint.new_service(());
|
||||||
|
|
||||||
// take extensions or create new one as app data container.
|
// take extensions or create new one as app data container.
|
||||||
let mut app_data = self
|
let mut app_data = self.extensions.borrow_mut().take().unwrap_or_default();
|
||||||
.extensions
|
|
||||||
.borrow_mut()
|
|
||||||
.take()
|
|
||||||
.unwrap_or_else(Extensions::new);
|
|
||||||
|
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
// async data factories
|
// async data factories
|
||||||
|
|
|
@ -167,7 +167,7 @@ mod tests {
|
||||||
async fn handler_min() {}
|
async fn handler_min() {}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[allow(clippy::too_many_arguments, clippy::just_underscores_and_digits)]
|
#[allow(clippy::too_many_arguments, clippy::just_underscores_and_digits, clippy::let_unit_value)]
|
||||||
async fn handler_max(
|
async fn handler_max(
|
||||||
_01: (), _02: (), _03: (), _04: (), _05: (), _06: (),
|
_01: (), _02: (), _03: (), _04: (), _05: (), _06: (),
|
||||||
_07: (), _08: (), _09: (), _10: (), _11: (), _12: (),
|
_07: (), _08: (), _09: (), _10: (), _11: (), _12: (),
|
||||||
|
|
|
@ -92,7 +92,7 @@ pub struct RouteService {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RouteService {
|
impl RouteService {
|
||||||
// TODO: does this need to take &mut ?
|
#[allow(clippy::needless_pass_by_ref_mut)]
|
||||||
pub fn check(&self, req: &mut ServiceRequest) -> bool {
|
pub fn check(&self, req: &mut ServiceRequest) -> bool {
|
||||||
let guard_ctx = req.guard_ctx();
|
let guard_ctx = req.guard_ctx();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue