mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-01 00:44:26 +02:00
clippy
This commit is contained in:
@ -276,7 +276,7 @@ impl AcceptEncoding {
|
||||
let mut encodings = raw
|
||||
.replace(' ', "")
|
||||
.split(',')
|
||||
.filter_map(|l| AcceptEncoding::new(l))
|
||||
.filter_map(AcceptEncoding::new)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
encodings.sort();
|
||||
|
@ -102,7 +102,7 @@ where
|
||||
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future {
|
||||
let error_handler = req
|
||||
.app_data::<PathConfig>()
|
||||
.and_then(|c| c.ehandler.clone());
|
||||
.and_then(|c| c.err_handler.clone());
|
||||
|
||||
ready(
|
||||
de::Deserialize::deserialize(PathDeserializer::new(req.match_info()))
|
||||
@ -158,9 +158,9 @@ where
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct PathConfig {
|
||||
ehandler: Option<Arc<dyn Fn(PathError, &HttpRequest) -> Error + Send + Sync>>,
|
||||
err_handler: Option<Arc<dyn Fn(PathError, &HttpRequest) -> Error + Send + Sync>>,
|
||||
}
|
||||
|
||||
impl PathConfig {
|
||||
@ -169,17 +169,11 @@ impl PathConfig {
|
||||
where
|
||||
F: Fn(PathError, &HttpRequest) -> Error + Send + Sync + 'static,
|
||||
{
|
||||
self.ehandler = Some(Arc::new(f));
|
||||
self.err_handler = Some(Arc::new(f));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for PathConfig {
|
||||
fn default() -> Self {
|
||||
PathConfig { ehandler: None }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_router::ResourceDef;
|
||||
|
@ -167,7 +167,7 @@ impl<T: DeserializeOwned> FromRequest for Query<T> {
|
||||
/// .app_data(query_cfg)
|
||||
/// .service(index);
|
||||
/// ```
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct QueryConfig {
|
||||
err_handler: Option<Arc<dyn Fn(QueryPayloadError, &HttpRequest) -> Error + Send + Sync>>,
|
||||
}
|
||||
@ -183,12 +183,6 @@ impl QueryConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for QueryConfig {
|
||||
fn default() -> Self {
|
||||
QueryConfig { err_handler: None }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_http::http::StatusCode;
|
||||
|
Reference in New Issue
Block a user