From d5606625a21803c2a627fdf2f2449c1c9d96ee02 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 4 Jul 2018 22:57:40 +0600 Subject: [PATCH] remove public Clone for Request --- src/httprequest.rs | 6 +++--- src/server/message.rs | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/httprequest.rs b/src/httprequest.rs index 56e95e9e6..08de0a8fe 100644 --- a/src/httprequest.rs +++ b/src/httprequest.rs @@ -74,7 +74,7 @@ impl HttpRequest { pub(crate) fn with_state(&self, state: Rc) -> HttpRequest { HttpRequest { state, - req: self.req.clone(), + req: self.req.as_ref().map(|r| r.clone()), route: self.route.clone(), } } @@ -84,7 +84,7 @@ impl HttpRequest { pub(crate) fn with_route_info(&self, route: RouteInfo) -> HttpRequest { HttpRequest { route, - req: self.req.clone(), + req: self.req.as_ref().map(|r| r.clone()), state: self.state.clone(), } } @@ -327,7 +327,7 @@ impl Drop for HttpRequest { impl Clone for HttpRequest { fn clone(&self) -> HttpRequest { HttpRequest { - req: self.req.clone(), + req: self.req.as_ref().map(|r| r.clone()), state: self.state.clone(), route: self.route.clone(), } diff --git a/src/server/message.rs b/src/server/message.rs index eb1395ac3..395d7b7c3 100644 --- a/src/server/message.rs +++ b/src/server/message.rs @@ -20,7 +20,6 @@ bitflags! { } /// Request's context -#[derive(Clone)] pub struct Request { pub(crate) inner: Rc, } @@ -196,6 +195,12 @@ impl Request { &self.inner().settings } + pub(crate) fn clone(&self) -> Self { + Request { + inner: self.inner.clone(), + } + } + pub(crate) fn release(self) { let mut inner = self.inner; if let Some(r) = Rc::get_mut(&mut inner) {