mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
Clippy warnings (#382)
This commit is contained in:
parent
2cbc42730b
commit
d39611d246
19 changed files with 33 additions and 43 deletions
|
@ -1015,7 +1015,7 @@ mod tests {
|
|||
|
||||
let (client, server) = IoTest::create();
|
||||
let f = DropFilter { p: p.clone() };
|
||||
format!("{:?}", f);
|
||||
let _ = format!("{:?}", f);
|
||||
let mut io = Io::new(server).add_filter(f);
|
||||
|
||||
client.remote_buffer_cap(1024);
|
||||
|
|
|
@ -496,7 +496,7 @@ mod tests {
|
|||
read_order: read_order.clone(),
|
||||
write_order: write_order.clone(),
|
||||
};
|
||||
format!("{:?}", counter);
|
||||
let _ = format!("{:?}", counter);
|
||||
let io = Io::new(server).add_filter(counter);
|
||||
|
||||
client.remote_buffer_cap(1024);
|
||||
|
|
|
@ -231,10 +231,7 @@ mod tests {
|
|||
ntex_service::fn_service(|_| async { Ok::<_, ()>(()) })
|
||||
});
|
||||
|
||||
let srv = Connector::default()
|
||||
.tag("T")
|
||||
.memory_pool(PoolId::P5)
|
||||
.clone();
|
||||
let srv = Connector::default().tag("T").memory_pool(PoolId::P5);
|
||||
let result = srv.connect("").await;
|
||||
assert!(result.is_err());
|
||||
let result = srv.connect("localhost:99999").await;
|
||||
|
|
|
@ -278,7 +278,7 @@ mod tests {
|
|||
let res = srv.call("srv").await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), ("srv", ()));
|
||||
format!("{:?}", srv);
|
||||
let _ = format!("{:?}", srv);
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
|
@ -301,7 +301,7 @@ mod tests {
|
|||
let res = srv.call("srv").await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), ("srv", ()));
|
||||
format!("{:?}", new_srv);
|
||||
let _ = format!("{:?}", new_srv);
|
||||
|
||||
assert!(Err == Err::from(()));
|
||||
}
|
||||
|
@ -322,6 +322,6 @@ mod tests {
|
|||
let res = srv.call("srv").await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), ("srv", ()));
|
||||
format!("{:?}", new_srv);
|
||||
let _ = format!("{:?}", new_srv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ mod tests {
|
|||
req: &'static str,
|
||||
ctx: ServiceCtx<'_, Self>,
|
||||
) -> Result<Self::Response, Self::Error> {
|
||||
format!("{:?}", ctx);
|
||||
let _ = format!("{:?}", ctx);
|
||||
#[allow(clippy::clone_on_copy)]
|
||||
let _ = ctx.clone();
|
||||
Ok(req)
|
||||
|
|
|
@ -380,20 +380,20 @@ mod tests {
|
|||
#[ntex::test]
|
||||
async fn test_fn_service() {
|
||||
let new_srv = fn_service(|()| async { Ok::<_, ()>("srv") }).clone();
|
||||
format!("{:?}", new_srv);
|
||||
let _ = format!("{:?}", new_srv);
|
||||
|
||||
let srv = Pipeline::new(new_srv.create(()).await.unwrap()).bind();
|
||||
let res = srv.call(()).await;
|
||||
assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(())));
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), "srv");
|
||||
format!("{:?}", srv);
|
||||
let _ = format!("{:?}", srv);
|
||||
|
||||
let srv2 = Pipeline::new(new_srv.clone()).bind();
|
||||
let res = srv2.call(()).await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), "srv");
|
||||
format!("{:?}", srv2);
|
||||
let _ = format!("{:?}", srv2);
|
||||
|
||||
assert_eq!(lazy(|cx| srv2.poll_shutdown(cx)).await, Poll::Ready(()));
|
||||
}
|
||||
|
|
|
@ -94,6 +94,6 @@ mod tests {
|
|||
pipe.shutdown().await;
|
||||
assert!(is_called.get());
|
||||
|
||||
format!("{:?}", pipe);
|
||||
let _ = format!("{:?}", pipe);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ mod tests {
|
|||
srv.shutdown().await;
|
||||
assert_eq!(cnt_sht.get(), 1);
|
||||
|
||||
format!("{:?}", srv);
|
||||
let _ = format!("{:?}", srv);
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
|
@ -208,7 +208,7 @@ mod tests {
|
|||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), ("ok"));
|
||||
|
||||
format!("{:?}", new_srv);
|
||||
let _ = format!("{:?}", new_srv);
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
|
@ -222,6 +222,6 @@ mod tests {
|
|||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), ("ok"));
|
||||
|
||||
format!("{:?}", new_srv);
|
||||
let _ = format!("{:?}", new_srv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ mod tests {
|
|||
|
||||
let _ = factory.create(&10).await;
|
||||
assert_eq!(item.get(), 11);
|
||||
format!("{:?}", factory);
|
||||
let _ = format!("{:?}", factory);
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
|
|
|
@ -209,7 +209,7 @@ mod tests {
|
|||
assert!(res.is_err());
|
||||
assert_eq!(res.err().unwrap(), "error");
|
||||
|
||||
format!("{:?}", srv);
|
||||
let _ = format!("{:?}", srv);
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
|
@ -223,7 +223,7 @@ mod tests {
|
|||
assert!(res.is_err());
|
||||
assert_eq!(res.err().unwrap(), "error");
|
||||
|
||||
format!("{:?}", srv);
|
||||
let _ = format!("{:?}", srv);
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
|
@ -236,7 +236,7 @@ mod tests {
|
|||
let res = srv.call(()).await;
|
||||
assert!(res.is_err());
|
||||
assert_eq!(res.err().unwrap(), "error");
|
||||
format!("{:?}", new_srv);
|
||||
let _ = format!("{:?}", new_srv);
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
|
@ -250,6 +250,6 @@ mod tests {
|
|||
let res = srv.call(()).await;
|
||||
assert!(res.is_err());
|
||||
assert_eq!(res.err().unwrap(), "error");
|
||||
format!("{:?}", new_srv);
|
||||
let _ = format!("{:?}", new_srv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ mod tests {
|
|||
|
||||
assert!(factory.create(&true).await.is_err());
|
||||
assert!(factory.create(&false).await.is_ok());
|
||||
format!("{:?}", factory);
|
||||
let _ = format!("{:?}", factory);
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
|
@ -108,6 +108,6 @@ mod tests {
|
|||
|
||||
assert!(factory.create(&true).await.is_err());
|
||||
assert!(factory.create(&false).await.is_ok());
|
||||
format!("{:?}", factory);
|
||||
let _ = format!("{:?}", factory);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ mod tests {
|
|||
let res = srv.call(10).await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), 20);
|
||||
format!("{:?} {:?}", factory, srv);
|
||||
let _ = format!("{:?} {:?}", factory, srv);
|
||||
|
||||
assert_eq!(srv.ready().await, Ok(()));
|
||||
srv.shutdown().await;
|
||||
|
@ -259,7 +259,7 @@ mod tests {
|
|||
let res = srv.call(10).await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), 20);
|
||||
format!("{:?} {:?}", factory, srv);
|
||||
let _ = format!("{:?} {:?}", factory, srv);
|
||||
|
||||
assert_eq!(srv.ready().await, Ok(()));
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ mod tests {
|
|||
let _ = tx.send(());
|
||||
crate::time::sleep(Duration::from_millis(25)).await;
|
||||
assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(())));
|
||||
assert_eq!(srv.shutdown().await, ());
|
||||
srv.shutdown().await;
|
||||
}
|
||||
|
||||
#[ntex_macros::rt_test2]
|
||||
|
|
|
@ -118,7 +118,7 @@ mod tests {
|
|||
let _ = tx.send(());
|
||||
crate::time::sleep(Duration::from_millis(25)).await;
|
||||
assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(())));
|
||||
assert_eq!(srv.shutdown().await, ());
|
||||
srv.shutdown().await;
|
||||
}
|
||||
|
||||
#[ntex_macros::rt_test2]
|
||||
|
|
|
@ -183,7 +183,7 @@ mod tests {
|
|||
Pipeline::new(TimeoutService::new(resolution, SleepService(wait_time)).clone());
|
||||
assert_eq!(timeout.call(()).await, Ok(()));
|
||||
assert_eq!(timeout.ready().await, Ok(()));
|
||||
assert_eq!(timeout.shutdown().await, ());
|
||||
timeout.shutdown().await;
|
||||
}
|
||||
|
||||
#[ntex_macros::rt_test2]
|
||||
|
|
|
@ -283,7 +283,7 @@ mod tests {
|
|||
let service = factory.pipeline(&()).await.unwrap().clone();
|
||||
|
||||
assert!(service.ready().await.is_ok());
|
||||
assert_eq!(service.shutdown().await, ());
|
||||
service.shutdown().await;
|
||||
|
||||
assert_eq!(service.call(Variant3::V1(())).await, Ok(1));
|
||||
assert_eq!(service.call(Variant3::V2(())).await, Ok(2));
|
||||
|
|
|
@ -15,6 +15,7 @@ categories = [
|
|||
]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.75"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["tokio", "openssl", "rustls", "compress", "cookie", "ws", "brotli"]
|
||||
|
|
|
@ -70,7 +70,7 @@ impl ConnectionInfo {
|
|||
if scheme.is_none() {
|
||||
if let Some(h) = req
|
||||
.headers
|
||||
.get(&HeaderName::from_lowercase(X_FORWARDED_PROTO).unwrap())
|
||||
.get(HeaderName::from_lowercase(X_FORWARDED_PROTO).unwrap())
|
||||
{
|
||||
if let Ok(h) = h.to_str() {
|
||||
scheme = h.split(',').next().map(|v| v.trim());
|
||||
|
@ -88,7 +88,7 @@ impl ConnectionInfo {
|
|||
if host.is_none() {
|
||||
if let Some(h) = req
|
||||
.headers
|
||||
.get(&HeaderName::from_lowercase(X_FORWARDED_HOST).unwrap())
|
||||
.get(HeaderName::from_lowercase(X_FORWARDED_HOST).unwrap())
|
||||
{
|
||||
if let Ok(h) = h.to_str() {
|
||||
host = h.split(',').next().map(|v| v.trim());
|
||||
|
@ -111,7 +111,7 @@ impl ConnectionInfo {
|
|||
if remote.is_none() {
|
||||
if let Some(h) = req
|
||||
.headers
|
||||
.get(&HeaderName::from_lowercase(X_FORWARDED_FOR).unwrap())
|
||||
.get(HeaderName::from_lowercase(X_FORWARDED_FOR).unwrap())
|
||||
{
|
||||
if let Ok(h) = h.to_str() {
|
||||
remote = h.split(',').next().map(|v| v.trim());
|
||||
|
|
|
@ -339,11 +339,7 @@ impl FormatText {
|
|||
}
|
||||
FormatText::ResponseHeader(ref name) => {
|
||||
let s = if let Some(val) = res.headers().get(name) {
|
||||
if let Ok(s) = val.to_str() {
|
||||
s
|
||||
} else {
|
||||
"-"
|
||||
}
|
||||
val.to_str().unwrap_or("-")
|
||||
} else {
|
||||
"-"
|
||||
};
|
||||
|
@ -380,11 +376,7 @@ impl FormatText {
|
|||
}
|
||||
FormatText::RequestHeader(ref name) => {
|
||||
let s = if let Some(val) = req.headers().get(name) {
|
||||
if let Ok(s) = val.to_str() {
|
||||
s
|
||||
} else {
|
||||
"-"
|
||||
}
|
||||
val.to_str().unwrap_or("-")
|
||||
} else {
|
||||
"-"
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue