pub fn insert_as_leaf(mut self, key: K, value: V) ->
            (InsertionResult<K, V>, *mut V) {
        if !self.node.is_full() {
            // The element can fit, just insert it
            (Fit, unsafe { self.node.insert_kv(self.index, key, value) as *mut _ })
        } else {
            // The element can't fit, this node is full. Split it into two nodes.
            let (new_key, new_val, mut new_right) = self.node.split();
            let left_len = self.node.len();

            let ptr = unsafe {
                if self.index <= left_len {
                    self.node.insert_kv(self.index, key, value)
                } else {
                    // We need to subtract 1 because in splitting we took out new_key and new_val.
                    // Just being in the right node means we are past left_len k/v pairs in the
                    // left node and 1 k/v pair in the parent node.
                    new_right.insert_kv(self.index - left_len - 1, key, value)
                }
            } as *mut _;

            (Split(new_key, new_val, new_right), ptr)
        }
    }
/// Tries to insert this key-value pair at the given index in this leaf node
/// If the node is full, we have to split it.
///
/// Returns a *mut V to the inserted value, because the caller may want this when
/// they're done mutating the tree, but we don't want to borrow anything for now.
Tries to insert this key-value pair at the given index in this leaf node
If the node is full, we have to split it.

Returns a *mut V to the inserted value, because the caller may want this when
they're done mutating the tree, but we don't want to borrow anything for now.
Tries to insert this key - value pair at the given index in this leaf node If the node is full we have to split it . Returns a * mut V to the inserted value because the caller may want this when they ' re done mutating the tree but we don ' t want to borrow anything for now .
pub fn insert_as_leaf(mut self, key: K, value: V) ->
            (InsertionResult<K, V>, *mut V) {
        if !self.node.is_full() {
            // The element can fit, just insert it
            (Fit, unsafe { self.node.insert_kv(self.index, key, value) as *mut _ })
        } else {
            // The element can't fit, this node is full. Split it into two nodes.
            let (new_key, new_val, mut new_right) = self.node.split();
            let left_len = self.node.len();
            let ptr = unsafe {
                if self.index <= left_len {
                    self.node.insert_kv(self.index, key, value)
                } else {
                    // We need to subtract 1 because in splitting we took out new_key and new_val.
                    // Just being in the right node means we are past left_len k/v pairs in the
                    // left node and 1 k/v pair in the parent node.
                    new_right.insert_kv(self.index - left_len - 1, key, value)
                }
            } as *mut _;
            (Split(new_key, new_val, new_right), ptr)
        }
    }
pub fn insert_as_leaf ( mut self , key : K , value : V ) -> ( InsertionResult < K , V > , * mut V ) { if ! self . node . is_full ( ) { // The element can fit, just insert it ( Fit , unsafe { self . node . insert_kv ( self . index , key , value ) as * mut _ } ) } else { // The element can't fit, this node is full. Split it into two nodes. let ( new_key , new_val , mut new_right ) = self . node . split ( ) ; let left_len = self . node . len ( ) ; let ptr = unsafe { if self . index <= left_len { self . node . insert_kv ( self . index , key , value ) } else { // We need to subtract 1 because in splitting we took out new_key and new_val. // Just being in the right node means we are past left_len k/v pairs in the // left node and 1 k/v pair in the parent node. new_right . insert_kv ( self . index - left_len - 1 , key , value ) } } as * mut _ ; ( Split ( new_key , new_val , new_right ) , ptr ) } }
Tries to insert this key-value pair at the given index in this leaf node
If the node is full, we have to split it.
Tries to insert this key - value pair at the given index in this leaf node If the node is full we have to split it .
mut self
key
K
value
V