From 69fee5864d9463d3646e89cf055019bc702c297b Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 19 Nov 2021 23:15:47 +0100 Subject: [PATCH] Use .to_owned() instead of .to_string() to turn &str into String (#548) --- axum-debug/src/lib.rs | 1 + axum-extra/src/lib.rs | 1 + axum-extra/src/routing/resource.rs | 2 +- axum/src/extract/raw_query.rs | 2 +- axum/src/lib.rs | 1 + axum/src/routing/mod.rs | 6 +++--- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/axum-debug/src/lib.rs b/axum-debug/src/lib.rs index 2d2ec686..76918a8b 100644 --- a/axum-debug/src/lib.rs +++ b/axum-debug/src/lib.rs @@ -109,6 +109,7 @@ clippy::option_option, clippy::verbose_file_reads, clippy::unnested_or_patterns, + clippy::str_to_string, rust_2018_idioms, future_incompatible, nonstandard_style, diff --git a/axum-extra/src/lib.rs b/axum-extra/src/lib.rs index d1c04dd3..e7f8384e 100644 --- a/axum-extra/src/lib.rs +++ b/axum-extra/src/lib.rs @@ -30,6 +30,7 @@ clippy::option_option, clippy::verbose_file_reads, clippy::unnested_or_patterns, + clippy::str_to_string, rust_2018_idioms, future_incompatible, nonstandard_style, diff --git a/axum-extra/src/routing/resource.rs b/axum-extra/src/routing/resource.rs index 046da840..adff26e4 100644 --- a/axum-extra/src/routing/resource.rs +++ b/axum-extra/src/routing/resource.rs @@ -59,7 +59,7 @@ impl Resource { /// All routes will be nested at `/{resource_name}`. pub fn named(resource_name: &str) -> Self { Self { - name: resource_name.to_string(), + name: resource_name.to_owned(), router: Default::default(), } } diff --git a/axum/src/extract/raw_query.rs b/axum/src/extract/raw_query.rs index f8d25393..463c31d8 100644 --- a/axum/src/extract/raw_query.rs +++ b/axum/src/extract/raw_query.rs @@ -34,7 +34,7 @@ where type Rejection = Infallible; async fn from_request(req: &mut RequestParts) -> Result { - let query = req.uri().query().map(|query| query.to_string()); + let query = req.uri().query().map(|query| query.to_owned()); Ok(Self(query)) } } diff --git a/axum/src/lib.rs b/axum/src/lib.rs index 98f45025..2f165f20 100644 --- a/axum/src/lib.rs +++ b/axum/src/lib.rs @@ -360,6 +360,7 @@ clippy::option_option, clippy::verbose_file_reads, clippy::unnested_or_patterns, + clippy::str_to_string, rust_2018_idioms, future_incompatible, nonstandard_style, diff --git a/axum/src/routing/mod.rs b/axum/src/routing/mod.rs index f557980c..f660a5cd 100644 --- a/axum/src/routing/mod.rs +++ b/axum/src/routing/mod.rs @@ -203,7 +203,7 @@ where for (id, nested_path) in node.route_id_to_path { let route = routes.remove(&id).unwrap(); let full_path = if &*nested_path == "/" { - path.to_string() + path.to_owned() } else { format!("{}{}", path, nested_path) }; @@ -427,7 +427,7 @@ where .params .iter() .filter(|(key, _)| !key.starts_with(NEST_TAIL_PARAM)) - .map(|(key, value)| (key.to_string(), value.to_string())) + .map(|(key, value)| (key.to_owned(), value.to_owned())) .collect::>(); insert_url_params(&mut req, params); @@ -477,7 +477,7 @@ where req.extensions_mut().insert(original_uri); } - let path = req.uri().path().to_string(); + let path = req.uri().path().to_owned(); match self.node.at(&path) { Ok(match_) => self.call_route(match_, req),