diff --git a/src/lib.rs b/src/lib.rs index 3c4459c..c137eb7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -166,12 +166,13 @@ impl ListHead { /// is still complete. #[inline(always)] unsafe fn add(&mut self, other: &mut ListHead) { + let next = self.next.assume_init_mut().as_mut(); + let other_ptr = other.ptr(); + other.prev.write(self.ptr()); other.next = self.next; - - let next = self.next.assume_init_mut().as_mut(); - next.prev.write(other.ptr()); - self.next.write(other.ptr()); + next.prev.write(other_ptr); + self.next.write(other_ptr); } #[inline(always)]