Skip to content

Commit

Permalink
Fix clippy for 1.60
Browse files Browse the repository at this point in the history
  • Loading branch information
samscott89 committed Apr 7, 2024
1 parent 25740d9 commit 641df62
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
17 changes: 5 additions & 12 deletions src/actix.rs
Expand Up @@ -134,6 +134,8 @@ where
}
}

type ActixErrorHandler = Option<Arc<dyn Fn(QsError, &HttpRequest) -> ActixError + Send + Sync>>;

/// Query extractor configuration
///
/// ```rust
Expand Down Expand Up @@ -173,9 +175,9 @@ where
/// );
/// }
/// ```
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct QsQueryConfig {
ehandler: Option<Arc<dyn Fn(QsError, &HttpRequest) -> ActixError + Send + Sync>>,
ehandler: ActixErrorHandler,
qs_config: QsConfig,
}

Expand All @@ -201,15 +203,6 @@ impl QsQueryConfig {
}
}

impl Default for QsQueryConfig {
fn default() -> Self {
QsQueryConfig {
ehandler: None,
qs_config: QsConfig::default(),
}
}
}

#[derive(PartialEq, Eq, PartialOrd, Ord)]
/// Extract typed information from from the request's form data.
///
Expand All @@ -230,7 +223,7 @@ impl Default for QsQueryConfig {
/// }
///
/// // Use `QsForm` extractor for Form information.
/// // Content-Type: application/x-www-form-urlencoded
/// // Content-Type: application/x-www-form-urlencoded
/// // The correct request payload for this handler would be `id[]=1124&id[]=88`
/// async fn filter_users(info: QsForm<UsersFilter>) -> HttpResponse {
/// HttpResponse::Ok().body(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_actix.rs
Expand Up @@ -26,7 +26,7 @@ where
S: std::str::FromStr,
{
let s = <&str as serde::Deserialize>::deserialize(deserializer)?;
S::from_str(&s).map_err(|_| D::Error::custom("could not parse string"))
S::from_str(s).map_err(|_| D::Error::custom("could not parse string"))
}

#[derive(Deserialize, Serialize, Debug, PartialEq)]
Expand Down Expand Up @@ -103,7 +103,7 @@ fn test_composite_querystring_extractor() {
assert_eq!(s.bars, vec![0, 1]);
assert_eq!(s.common.limit, 100);
assert_eq!(s.common.offset, 50);
assert_eq!(s.common.remaining, true);
assert!(s.common.remaining);
})
}

Expand Down Expand Up @@ -140,7 +140,7 @@ fn test_custom_qs_config() {
assert_eq!(s.bars, vec![3]);
assert_eq!(s.common.limit, 100);
assert_eq!(s.common.offset, 50);
assert_eq!(s.common.remaining, true);
assert!(s.common.remaining);
})
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_deserialize.rs
Expand Up @@ -81,7 +81,7 @@ fn deserialize_struct() {
user_ids: vec![1, 2, 3, 4],
};

for config in vec![qs::Config::new(5, true), qs::Config::new(5, false)] {
for config in [qs::Config::new(5, true), qs::Config::new(5, false)] {
// standard parameters
let rec_params: QueryParams = config
.deserialize_str(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_warp.rs
Expand Up @@ -17,7 +17,7 @@ where
S: std::str::FromStr,
{
let s = <&str as serde::Deserialize>::deserialize(deserializer)?;
S::from_str(&s).map_err(|_| D::Error::custom("could not parse string"))
S::from_str(s).map_err(|_| D::Error::custom("could not parse string"))
}

#[derive(Deserialize, Serialize, Debug, PartialEq)]
Expand Down Expand Up @@ -65,7 +65,7 @@ fn test_composite_querystring_extractor() {
assert_eq!(s.bars, vec![0, 1]);
assert_eq!(s.common.limit, 100);
assert_eq!(s.common.offset, 50);
assert_eq!(s.common.remaining, true);
assert!(s.common.remaining);
})
}

Expand Down Expand Up @@ -99,6 +99,6 @@ fn test_custom_qs_config() {
assert_eq!(s.bars, vec![3]);
assert_eq!(s.common.limit, 100);
assert_eq!(s.common.offset, 50);
assert_eq!(s.common.remaining, true);
assert!(s.common.remaining);
})
}

0 comments on commit 641df62

Please sign in to comment.