1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::{Item, Key, Node, Value, ARRAY_SIZE};

impl<K: Key, V: Value> Node<K, V> {
    pub fn take_items(&mut self) -> [Option<Box<Item<K, V>>>; ARRAY_SIZE] {
        let items = self.items.to_owned();
        self.items = Default::default();
        items
    }

    pub fn take_child(&mut self, index: usize) -> Option<Box<Node<K, V>>> {
        let child = self.children[index].to_owned();
        self.children[index] = None;
        child
    }

    pub fn take_child_size(&mut self, index: usize) -> usize {
        let child = self.children_size[index].to_owned();
        self.children_size[index] = 0;
        child
    }
}