address new clippy lints

This commit is contained in:
Rob Ede 2023-07-01 23:47:46 +01:00
parent 56030447e9
commit f08e7cd300
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
4 changed files with 6 additions and 12 deletions

View File

@ -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())
}
}

View File

@ -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

View File

@ -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);
///

View File

@ -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());