1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-30 18:44:35 +01:00

simplify linked nodes

This commit is contained in:
Nikolay Kim 2018-03-03 10:06:13 -08:00
parent 9bd6cb03ac
commit f456be0309

View File

@ -95,7 +95,7 @@ impl<T, H> Future for HttpChannel<T, H> where T: IoStream, H: HttpHandler + 'sta
match result { match result {
Ok(Async::Ready(())) | Err(_) => { Ok(Async::Ready(())) | Err(_) => {
h1.settings().remove_channel(); h1.settings().remove_channel();
self.node.as_ref().unwrap().remove(); self.node.as_mut().unwrap().remove();
}, },
_ => (), _ => (),
} }
@ -106,7 +106,7 @@ impl<T, H> Future for HttpChannel<T, H> where T: IoStream, H: HttpHandler + 'sta
match result { match result {
Ok(Async::Ready(())) | Err(_) => { Ok(Async::Ready(())) | Err(_) => {
h2.settings().remove_channel(); h2.settings().remove_channel();
self.node.as_ref().unwrap().remove(); self.node.as_mut().unwrap().remove();
}, },
_ => (), _ => (),
} }
@ -186,13 +186,15 @@ impl<T> Node<T>
} }
} }
fn remove(&self) { fn remove(&mut self) {
#[allow(mutable_transmutes)] #[allow(mutable_transmutes)]
unsafe { unsafe {
if let Some(ref prev) = self.prev { let mut prev = self.prev.take();
let next = self.next.take();
if let Some(ref mut prev) = prev {
let p: &mut Node<()> = mem::transmute(prev.as_ref().unwrap()); let p: &mut Node<()> = mem::transmute(prev.as_ref().unwrap());
let slf: &mut Node<T> = mem::transmute(self); p.next = next;
p.next = slf.next.take();
} }
} }
} }