mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-01 16:55:08 +02:00
improve code readability
This commit is contained in:
@ -38,7 +38,7 @@ pub struct App<T, B> {
|
||||
data_factories: Vec<FnDataFactory>,
|
||||
external: Vec<ResourceDef>,
|
||||
extensions: Extensions,
|
||||
_t: PhantomData<B>,
|
||||
_phantom: PhantomData<B>,
|
||||
}
|
||||
|
||||
impl App<AppEntry, Body> {
|
||||
@ -55,7 +55,7 @@ impl App<AppEntry, Body> {
|
||||
factory_ref: fref,
|
||||
external: Vec::new(),
|
||||
extensions: Extensions::new(),
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -381,7 +381,7 @@ where
|
||||
factory_ref: self.factory_ref,
|
||||
external: self.external,
|
||||
extensions: self.extensions,
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ where
|
||||
factory_ref: self.factory_ref,
|
||||
external: self.external,
|
||||
extensions: self.extensions,
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ where
|
||||
),
|
||||
config,
|
||||
rmap,
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ where
|
||||
data: Rc<[Box<dyn DataFactory>]>,
|
||||
extensions: Option<Extensions>,
|
||||
|
||||
_t: PhantomData<B>,
|
||||
_phantom: PhantomData<B>,
|
||||
}
|
||||
|
||||
impl<T, B> Future for AppInitResult<T, B>
|
||||
|
@ -49,7 +49,7 @@ where
|
||||
R::Output: Responder,
|
||||
{
|
||||
hnd: F,
|
||||
_t: PhantomData<(T, R)>,
|
||||
_phantom: PhantomData<(T, R)>,
|
||||
}
|
||||
|
||||
impl<F, T, R> HandlerService<F, T, R>
|
||||
@ -62,7 +62,7 @@ where
|
||||
pub fn new(hnd: F) -> Self {
|
||||
Self {
|
||||
hnd,
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ where
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
hnd: self.hnd.clone(),
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ impl ConnectionInfo {
|
||||
host = Some(val.trim());
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ where
|
||||
CompressResponse {
|
||||
encoding,
|
||||
fut: self.service.call(req),
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -119,7 +119,7 @@ where
|
||||
#[pin]
|
||||
fut: S::Future,
|
||||
encoding: ContentEncoding,
|
||||
_t: PhantomData<B>,
|
||||
_phantom: PhantomData<B>,
|
||||
}
|
||||
|
||||
impl<S, B> Future for CompressResponse<S, B>
|
||||
|
@ -236,7 +236,7 @@ where
|
||||
fut: self.service.call(req),
|
||||
format: None,
|
||||
time: OffsetDateTime::now_utc(),
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
} else {
|
||||
let now = OffsetDateTime::now_utc();
|
||||
@ -249,7 +249,7 @@ where
|
||||
fut: self.service.call(req),
|
||||
format: Some(format),
|
||||
time: now,
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ where
|
||||
fut: S::Future,
|
||||
time: OffsetDateTime,
|
||||
format: Option<Format>,
|
||||
_t: PhantomData<B>,
|
||||
_phantom: PhantomData<B>,
|
||||
}
|
||||
|
||||
impl<S, B> Future for LoggerResponse<S, B>
|
||||
@ -522,7 +522,7 @@ impl FormatText {
|
||||
};
|
||||
*self = FormatText::Str(s.to_string())
|
||||
}
|
||||
_ => (),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,7 +587,7 @@ impl FormatText {
|
||||
|
||||
*self = s;
|
||||
}
|
||||
_ => (),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -349,14 +349,14 @@ where
|
||||
pub struct ResponseFuture<T, E> {
|
||||
#[pin]
|
||||
fut: T,
|
||||
_t: PhantomData<E>,
|
||||
_phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<T, E> ResponseFuture<T, E> {
|
||||
pub fn new(fut: T) -> Self {
|
||||
ResponseFuture {
|
||||
fut,
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{
|
||||
any::Any,
|
||||
fmt, io,
|
||||
cmp, fmt, io,
|
||||
marker::PhantomData,
|
||||
net,
|
||||
sync::{Arc, Mutex},
|
||||
@ -71,7 +71,7 @@ where
|
||||
sockets: Vec<Socket>,
|
||||
builder: ServerBuilder,
|
||||
on_connect_fn: Option<Arc<dyn Fn(&dyn Any, &mut Extensions) + Send + Sync>>,
|
||||
_t: PhantomData<(S, B)>,
|
||||
_phantom: PhantomData<(S, B)>,
|
||||
}
|
||||
|
||||
impl<F, I, S, B> HttpServer<F, I, S, B>
|
||||
@ -100,7 +100,7 @@ where
|
||||
sockets: Vec::new(),
|
||||
builder: ServerBuilder::default(),
|
||||
on_connect_fn: None,
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ where
|
||||
sockets: self.sockets,
|
||||
builder: self.builder,
|
||||
on_connect_fn: Some(Arc::new(f)),
|
||||
_t: PhantomData,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ fn create_tcp_listener(
|
||||
socket.set_reuse_address(true)?;
|
||||
socket.bind(&addr.into())?;
|
||||
// clamp backlog to max u32 that fits in i32 range
|
||||
let backlog = backlog.min(i32::MAX as u32) as i32;
|
||||
let backlog = cmp::min(backlog, i32::MAX as u32) as i32;
|
||||
socket.listen(backlog)?;
|
||||
Ok(socket.into_tcp_listener())
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ mod tests {
|
||||
.into_parts();
|
||||
let res = HttpMessageBody::new(&req, &mut pl).await;
|
||||
match res.err().unwrap() {
|
||||
PayloadError::UnknownLength => (),
|
||||
PayloadError::UnknownLength => {},
|
||||
_ => unreachable!("error"),
|
||||
}
|
||||
|
||||
@ -548,7 +548,7 @@ mod tests {
|
||||
.into_parts();
|
||||
let res = HttpMessageBody::new(&req, &mut pl).await;
|
||||
match res.err().unwrap() {
|
||||
PayloadError::Overflow => (),
|
||||
PayloadError::Overflow => {},
|
||||
_ => unreachable!("error"),
|
||||
}
|
||||
|
||||
@ -563,7 +563,7 @@ mod tests {
|
||||
.to_http_parts();
|
||||
let res = HttpMessageBody::new(&req, &mut pl).limit(5).await;
|
||||
match res.err().unwrap() {
|
||||
PayloadError::Overflow => (),
|
||||
PayloadError::Overflow => {},
|
||||
_ => unreachable!("error"),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user