From af598fb872d2cfeb6546953f970b1f7cdeff0cb7 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Thu, 25 Mar 2021 18:17:51 -0700 Subject: [PATCH] Use concrete lifetime in 'Request::uri()'. --- core/lib/src/request/request.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/lib/src/request/request.rs b/core/lib/src/request/request.rs index 547db11d..0b05be59 100644 --- a/core/lib/src/request/request.rs +++ b/core/lib/src/request/request.rs @@ -139,7 +139,7 @@ impl<'r> Request<'r> { /// assert_eq!(get("/hello").uri().query(), None); /// ``` #[inline(always)] - pub fn uri(&self) -> &Origin<'_> { + pub fn uri(&self) -> &Origin<'r> { &self.uri } @@ -157,9 +157,14 @@ impl<'r> Request<'r> { /// request.set_uri(uri); /// assert_eq!(request.uri().path(), "/hello/Sergio"); /// assert_eq!(request.uri().query().unwrap(), "type=greeting"); + /// + /// let new_uri = request.uri().map_path(|p| format!("/foo{}", p)).unwrap(); + /// request.set_uri(new_uri); + /// assert_eq!(request.uri().path(), "/foo/hello/Sergio"); + /// assert_eq!(request.uri().query().unwrap(), "type=greeting"); /// # }); /// ``` - pub fn set_uri<'u: 'r>(&mut self, uri: Origin<'u>) { + pub fn set_uri(&mut self, uri: Origin<'r>) { self.uri = uri; }