1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-09-01 01:16:59 +02:00

Reduced unsafe converage (#520)

This commit is contained in:
Ashley
2018-09-26 20:56:34 +12:00
committed by Douman
parent 1b298142e3
commit 782eeb5ded
5 changed files with 121 additions and 99 deletions

View File

@@ -209,31 +209,35 @@ impl<T> Node<T> {
}
fn insert<I>(&mut self, next_el: &mut Node<I>) {
unsafe {
let next: *mut Node<T> = next_el as *const _ as *mut _;
let next: *mut Node<T> = next_el as *const _ as *mut _;
if let Some(next2) = self.next {
if let Some(next2) = self.next {
unsafe {
let n = next2.as_mut().unwrap();
n.prev = Some(next);
next_el.next = Some(next2 as *mut _);
}
self.next = Some(next);
next_el.next = Some(next2 as *mut _);
}
self.next = Some(next);
unsafe {
let next: &mut Node<T> = &mut *next;
next.prev = Some(self as *mut _);
}
}
fn remove(&mut self) {
unsafe {
self.element = ptr::null_mut();
let next = self.next.take();
let prev = self.prev.take();
self.element = ptr::null_mut();
let next = self.next.take();
let prev = self.prev.take();
if let Some(prev) = prev {
if let Some(prev) = prev {
unsafe {
prev.as_mut().unwrap().next = next;
}
if let Some(next) = next {
}
if let Some(next) = next {
unsafe {
next.as_mut().unwrap().prev = prev;
}
}