From 9ff042778cc53648ac2b6697d504d800834a2666 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 1 Feb 2026 10:47:31 +0900 Subject: [PATCH] Do not require major bump --- actix-web/src/request.rs | 2 +- actix-web/src/rmap.rs | 35 +++++++++++++---------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/actix-web/src/request.rs b/actix-web/src/request.rs index d14fa4da9..74654a6bc 100644 --- a/actix-web/src/request.rs +++ b/actix-web/src/request.rs @@ -243,7 +243,7 @@ impl HttpRequest { U: IntoIterator, I: AsRef, { - self.resource_map().url_for_iter(self, name, elements) + self.resource_map().url_for(self, name, elements) } /// Generates URL for a named resource. diff --git a/actix-web/src/rmap.rs b/actix-web/src/rmap.rs index bf9002b23..65fae60b9 100644 --- a/actix-web/src/rmap.rs +++ b/actix-web/src/rmap.rs @@ -119,7 +119,7 @@ impl ResourceMap { /// Generate URL for named resource with an iterator over elements. /// /// Check [`HttpRequest::url_for`] for detailed information. - pub fn url_for_iter( + pub fn url_for( &self, req: &HttpRequest, name: &str, @@ -130,7 +130,7 @@ impl ResourceMap { I: AsRef, { let mut elements = elements.into_iter(); - self.url_for(req, name, |mut acc, node: &ResourceMap| { + self.url_for_with(req, name, |mut acc, node: &ResourceMap| { node.pattern .resource_path_from_iter(&mut acc, &mut elements) .then_some(acc) @@ -151,14 +151,14 @@ impl ResourceMap { V: AsRef, S: BuildHasher, { - self.url_for(req, name, |mut acc, node: &ResourceMap| { + self.url_for_with(req, name, |mut acc, node: &ResourceMap| { node.pattern .resource_path_from_map(&mut acc, elements) .then_some(acc) }) } - fn url_for( + fn url_for_with( &self, req: &HttpRequest, name: &str, @@ -485,7 +485,7 @@ mod tests { const OUTPUT: &str = "http://localhost:8888/user/u123/post/foobar"; let url = rmap - .url_for_iter(&req, "post", ["u123", "foobar"]) + .url_for(&req, "post", ["u123", "foobar"]) .unwrap() .to_string(); assert_eq!(url, OUTPUT); @@ -497,7 +497,7 @@ mod tests { .to_string(); assert_eq!(url, OUTPUT); - assert!(rmap.url_for_iter(&req, "missing", ["u123"]).is_err()); + assert!(rmap.url_for(&req, "missing", ["u123"]).is_err()); assert!(rmap.url_for_map(&req, "missing", &input_map).is_err()); } @@ -530,25 +530,21 @@ mod tests { const OUTPUT: &str = "/quick%20brown%20fox/%nan%3Fquery%23frag"; - let url = rmap.url_for_iter(&req, "internal", ITERABLE_INPUT).unwrap(); + let url = rmap.url_for(&req, "internal", ITERABLE_INPUT).unwrap(); assert_eq!(url.path(), OUTPUT); let url = rmap.url_for_map(&req, "internal", &map_input).unwrap(); assert_eq!(url.path(), OUTPUT); - let url = rmap - .url_for_iter(&req, "external.1", ITERABLE_INPUT) - .unwrap(); + let url = rmap.url_for(&req, "external.1", ITERABLE_INPUT).unwrap(); assert_eq!(url.path(), OUTPUT); let url = rmap.url_for_map(&req, "external.1", &map_input).unwrap(); assert_eq!(url.path(), OUTPUT); - assert!(rmap - .url_for_iter(&req, "external.2", ITERABLE_INPUT) - .is_err()); + assert!(rmap.url_for(&req, "external.2", ITERABLE_INPUT).is_err()); assert!(rmap.url_for_map(&req, "external.2", &map_input).is_err()); let empty_map: HashMap<&str, &str> = HashMap::new(); - assert!(rmap.url_for_iter(&req, "external.2", [""]).is_err()); + assert!(rmap.url_for(&req, "external.2", [""]).is_err()); assert!(rmap.url_for_map(&req, "external.2", &empty_map).is_err()); } @@ -585,9 +581,7 @@ mod tests { const OUTPUT: &str = "https://duck.com/abcd"; assert_eq!( - rmap.url_for_iter(&req, "duck", ["abcd"]) - .unwrap() - .to_string(), + rmap.url_for(&req, "duck", ["abcd"]).unwrap().to_string(), OUTPUT ); @@ -625,10 +619,7 @@ mod tests { const OUTPUT: &str = "http://localhost:8080/bar/nested"; - let url = rmap - .url_for_iter(&req, "nested", [""; 0]) - .unwrap() - .to_string(); + let url = rmap.url_for(&req, "nested", [""; 0]).unwrap().to_string(); assert_eq!(url, OUTPUT); let empty_map: HashMap<&str, &str> = HashMap::new(); @@ -638,7 +629,7 @@ mod tests { .to_string(); assert_eq!(url, OUTPUT); - assert!(rmap.url_for_iter(&req, "missing", ["u123"]).is_err()); + assert!(rmap.url_for(&req, "missing", ["u123"]).is_err()); assert!(rmap.url_for_map(&req, "missing", &empty_map).is_err()); } }