Removes the child of the [Node] at the given index. # Panics This function will panic if the [Node] type does not support children.
(&mut self, index: u8)
| 237 | /// |
| 238 | /// This function will panic if the [Node] type does not support children. |
| 239 | pub fn remove_child(&mut self, index: u8) -> Result<(), NodeError> { |
| 240 | match self.0.kind { |
| 241 | NodeKind::AccountLeaf { ref mut storage_root, .. } => { |
| 242 | *storage_root = None; |
| 243 | Ok(()) |
| 244 | } |
| 245 | NodeKind::Branch { ref mut children } => { |
| 246 | children[index as usize] = None; |
| 247 | Ok(()) |
| 248 | } |
| 249 | _ => Err(NodeError::ChildrenUnsupported), |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | /// Returns the value of the [Node]. |
| 254 | /// |