fn leafify(&mut self) {
            unsafe {
                let mut top_raw = self.top;
                let mut top = top_raw.from_raw_mut();

                let key_ptr = top.key_mut() as *mut _;
                let val_ptr = top.val_mut() as *mut _;

                // Try to go into the right subtree of the found key to find its successor
                let mut right_edge = top.right_edge();
                let right_edge_raw = right_edge.as_raw();
                match right_edge.edge_mut() {
                    None => {
                        // We're a proper leaf stack, nothing to do
                    }
                    Some(mut temp_node) => {
                        //We're not a proper leaf stack, let's get to work.
                        self.stack.push(right_edge_raw);
                        loop {
                            // Walk into the smallest subtree of this node
                            let node = temp_node;

                            if node.is_leaf() {
                                // This node is a leaf, do the swap and return
                                let mut handle = node.kv_handle(0);
                                self.top = handle.as_raw();
                                mem::swap(handle.key_mut(), &mut *key_ptr);
                                mem::swap(handle.val_mut(), &mut *val_ptr);
                                break;
                            } else {
                                // This node is internal, go deeper
                                let mut handle = node.edge_handle(0);
                                self.stack.push(handle.as_raw());
                                temp_node = handle.into_edge_mut().unwrap();
                            }
                        }
                    }
                }
            }
        }
/// Subroutine for removal. Takes a search stack for a key that might terminate at an
/// internal node, and mutates the tree and search stack to *make* it a search stack
/// for that same key that *does* terminates at a leaf. If the mutation occurs, then this
/// leaves the tree in an inconsistent state that must be repaired by the caller by
/// removing the entry in question. Specifically the key-value pair and its successor will
/// become swapped.
Subroutine for removal. Takes a search stack for a key that might terminate at an
internal node, and mutates the tree and search stack to *make* it a search stack
for that same key that *does* terminates at a leaf. If the mutation occurs, then this
leaves the tree in an inconsistent state that must be repaired by the caller by
removing the entry in question. Specifically the key-value pair and its successor will
become swapped.
Subroutine for removal . Takes a search stack for a key that might terminate at an internal node and mutates the tree and search stack to * make * it a search stack for that same key that * does * terminates at a leaf . If the mutation occurs then this leaves the tree in an inconsistent state that must be repaired by the caller by removing the entry in question . Specifically the key - value pair and its successor will become swapped .
fn leafify(&mut self) {
            unsafe {
                let mut top_raw = self.top;
                let mut top = top_raw.from_raw_mut();
                let key_ptr = top.key_mut() as *mut _;
                let val_ptr = top.val_mut() as *mut _;
                // Try to go into the right subtree of the found key to find its successor
                let mut right_edge = top.right_edge();
                let right_edge_raw = right_edge.as_raw();
                match right_edge.edge_mut() {
                    None => {
                        // We're a proper leaf stack, nothing to do
                    }
                    Some(mut temp_node) => {
                        //We're not a proper leaf stack, let's get to work.
                        self.stack.push(right_edge_raw);
                        loop {
                            // Walk into the smallest subtree of this node
                            let node = temp_node;
                            if node.is_leaf() {
                                // This node is a leaf, do the swap and return
                                let mut handle = node.kv_handle(0);
                                self.top = handle.as_raw();
                                mem::swap(handle.key_mut(), &mut *key_ptr);
                                mem::swap(handle.val_mut(), &mut *val_ptr);
                                break;
                            } else {
                                // This node is internal, go deeper
                                let mut handle = node.edge_handle(0);
                                self.stack.push(handle.as_raw());
                                temp_node = handle.into_edge_mut().unwrap();
                            }
                        }
                    }
                }
            }
        }
fn leafify ( & mut self ) { unsafe { let mut top_raw = self . top ; let mut top = top_raw . from_raw_mut ( ) ; let key_ptr = top . key_mut ( ) as * mut _ ; let val_ptr = top . val_mut ( ) as * mut _ ; // Try to go into the right subtree of the found key to find its successor let mut right_edge = top . right_edge ( ) ; let right_edge_raw = right_edge . as_raw ( ) ; match right_edge . edge_mut ( ) { None => { // We're a proper leaf stack, nothing to do } Some ( mut temp_node ) => { //We're not a proper leaf stack, let's get to work. self . stack . push ( right_edge_raw ) ; loop { // Walk into the smallest subtree of this node let node = temp_node ; if node . is_leaf ( ) { // This node is a leaf, do the swap and return let mut handle = node . kv_handle ( 0 ) ; self . top = handle . as_raw ( ) ; mem :: swap ( handle . key_mut ( ) , & mut * key_ptr ) ; mem :: swap ( handle . val_mut ( ) , & mut * val_ptr ) ; break ; } else { // This node is internal, go deeper let mut handle = node . edge_handle ( 0 ) ; self . stack . push ( handle . as_raw ( ) ) ; temp_node = handle . into_edge_mut ( ) . unwrap ( ) ; } } } } } }
Subroutine for removal.
Subroutine for removal .
&mut self