mirror of https://github.com/fafhrd91/actix-web
address new clippy lints
This commit is contained in:
parent
56030447e9
commit
f08e7cd300
|
@ -270,8 +270,8 @@ impl<B> ErrorHandlers<B> {
|
|||
handlers
|
||||
.get(status)
|
||||
.map(|h| h.as_ref())
|
||||
.or_else(|| status.is_client_error().then(|| default_client).flatten())
|
||||
.or_else(|| status.is_server_error().then(|| default_server).flatten())
|
||||
.or_else(|| status.is_client_error().then_some(default_client).flatten())
|
||||
.or_else(|| status.is_server_error().then_some(default_server).flatten())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,12 @@ use crate::{
|
|||
///
|
||||
/// The default is `TrailingSlash::Trim`.
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub enum TrailingSlash {
|
||||
/// Trim trailing slashes from the end of the path.
|
||||
///
|
||||
/// Using this will require all routes to omit trailing slashes for them to be accessible.
|
||||
#[default]
|
||||
Trim,
|
||||
|
||||
/// Only merge any present multiple trailing slashes.
|
||||
|
@ -33,12 +34,6 @@ pub enum TrailingSlash {
|
|||
Always,
|
||||
}
|
||||
|
||||
impl Default for TrailingSlash {
|
||||
fn default() -> Self {
|
||||
TrailingSlash::Trim
|
||||
}
|
||||
}
|
||||
|
||||
/// Middleware for normalizing a request's path so that routes can be matched more flexibly.
|
||||
///
|
||||
/// # Normalization Steps
|
||||
|
|
|
@ -27,7 +27,6 @@ use crate::{
|
|||
/// # Examples
|
||||
/// ```no_run
|
||||
/// # use actix_web::{web, HttpResponse, HttpRequest, Responder, HttpMessage as _};
|
||||
///
|
||||
/// #[derive(Debug, Clone, PartialEq)]
|
||||
/// struct FlagFromMiddleware(String);
|
||||
///
|
||||
|
|
|
@ -136,7 +136,7 @@ impl ResourceMap {
|
|||
.root_rmap_fn(String::with_capacity(AVG_PATH_LEN), |mut acc, node| {
|
||||
node.pattern
|
||||
.resource_path_from_iter(&mut acc, &mut elements)
|
||||
.then(|| acc)
|
||||
.then_some(acc)
|
||||
})
|
||||
.ok_or(UrlGenerationError::NotEnoughElements)?;
|
||||
|
||||
|
@ -149,7 +149,7 @@ impl ResourceMap {
|
|||
// external resource; third slash would be the root slash in the path
|
||||
let third_slash_index = path
|
||||
.char_indices()
|
||||
.filter_map(|(i, c)| (c == '/').then(|| i))
|
||||
.filter_map(|(i, c)| (c == '/').then_some(i))
|
||||
.nth(2)
|
||||
.unwrap_or(path.len());
|
||||
|
||||
|
|
Loading…
Reference in New Issue