Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct IntrusiveNodeObject<T> {
- next: *mut IntrusiveNodeObject<T>,
- prev: *mut IntrusiveNodeObject<T>,
- list: *mut List<T>
- }
- struct List<T> {
- root: *mut IntrusiveNodeObject<T>
- }
- impl List<T> {
- pub fn push_back(&mut self, item: &mut Pin<Box<IntrusiveNodeObject<T>>>) {
- unsafe{
- //NOTE: is weakening the &mut to *mut enough to avoid moving out the underlyign value?
- let inner = item.as_mut().get_mut();
- // NOTE: would be this a problem?
- //let mut moved_or_reborrow = &mut *inner_mut_raw;
- //ERROR, cannot compile: cannot move out of dereference of raw pointer
- //let mut moved = *inner_mut_raw;
- if self.root.is_null() {
- inner.next = inner;
- inner.prev = inner;
- self.root = inner;
- inner.list = self;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement