From 0f2aac1a27d20e08cdc43bc7167799175a64c50b Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 17 Jun 2018 08:32:22 +0600 Subject: [PATCH] remove unneed Send and Sync --- src/middleware/identity.rs | 5 ----- src/middleware/session.rs | 5 ----- src/ws/client.rs | 19 ++++--------------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/src/middleware/identity.rs b/src/middleware/identity.rs index 706dd9fc8..58cc0de40 100644 --- a/src/middleware/identity.rs +++ b/src/middleware/identity.rs @@ -177,11 +177,6 @@ impl IdentityService { struct IdentityBox(Box); -#[doc(hidden)] -unsafe impl Send for IdentityBox {} -#[doc(hidden)] -unsafe impl Sync for IdentityBox {} - impl> Middleware for IdentityService { fn start(&mut self, req: &mut HttpRequest) -> Result { let mut req = req.clone(); diff --git a/src/middleware/session.rs b/src/middleware/session.rs index bd96a2360..bb6c82233 100644 --- a/src/middleware/session.rs +++ b/src/middleware/session.rs @@ -221,11 +221,6 @@ impl FromRequest for Session { struct SessionImplCell(RefCell>); -#[doc(hidden)] -unsafe impl Send for SessionImplCell {} -#[doc(hidden)] -unsafe impl Sync for SessionImplCell {} - /// Session storage middleware /// /// ```rust diff --git a/src/ws/client.rs b/src/ws/client.rs index 6cb661737..7cf0095d6 100644 --- a/src/ws/client.rs +++ b/src/ws/client.rs @@ -445,20 +445,13 @@ impl fmt::Debug for ClientReader { } } -impl ClientReader { - #[inline] - fn as_mut(&mut self) -> &mut Inner { - unsafe { &mut *self.inner.get() } - } -} - impl Stream for ClientReader { type Item = Message; type Error = ProtocolError; fn poll(&mut self) -> Poll, Self::Error> { let max_size = self.max_size; - let inner = self.as_mut(); + let inner: &mut Inner = unsafe { &mut *self.inner.get() }; if inner.closed { return Ok(Async::Ready(None)); } @@ -521,18 +514,14 @@ impl ClientWriter { /// Write payload #[inline] fn write(&mut self, mut data: Binary) { - if !self.as_mut().closed { - let _ = self.as_mut().tx.unbounded_send(data.take()); + let inner: &mut Inner = unsafe { &mut *self.inner.get() }; + if !inner.closed { + let _ = inner.tx.unbounded_send(data.take()); } else { warn!("Trying to write to disconnected response"); } } - #[inline] - fn as_mut(&mut self) -> &mut Inner { - unsafe { &mut *self.inner.get() } - } - /// Send text frame #[inline] pub fn text>(&mut self, text: T) {