Try to insert `(key, node)` at key-position `index` in an inner node. This means that `key` is inserted at `keys[i]` and `node` is inserted at `tree[i + 1]`. If the node is full, this leaves the node unchanged and returns false.
(&mut self, index: usize, key: F::Key, node: Node)
| 165 | /// This means that `key` is inserted at `keys[i]` and `node` is inserted at `tree[i + 1]`. |
| 166 | /// If the node is full, this leaves the node unchanged and returns false. |
| 167 | pub fn try_inner_insert(&mut self, index: usize, key: F::Key, node: Node) -> bool { |
| 168 | match *self { |
| 169 | Self::Inner { |
| 170 | ref mut size, |
| 171 | ref mut keys, |
| 172 | ref mut tree, |
| 173 | } => { |
| 174 | let sz = usize::from(*size); |
| 175 | debug_assert!(sz <= keys.len()); |
| 176 | debug_assert!(index <= sz, "Can't insert at {index} with {sz} keys"); |
| 177 | |
| 178 | if let Some(ks) = keys.get_mut(0..=sz) { |
| 179 | *size = (sz + 1) as u8; |
| 180 | slice_insert(ks, index, key); |
| 181 | slice_insert(&mut tree[1..=sz + 1], index, node); |
| 182 | true |
| 183 | } else { |
| 184 | false |
| 185 | } |
| 186 | } |
| 187 | _ => panic!("Expected inner node"), |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /// Try to insert `key, value` at `index` in a leaf node, but fail and return false if the node |
| 192 | /// is full. |
no test coverage detected