Unwrap a leaf node into two slices (keys, values) of the same length.
(&self)
| 113 | |
| 114 | /// Unwrap a leaf node into two slices (keys, values) of the same length. |
| 115 | pub fn unwrap_leaf(&self) -> (&[F::Key], &[F::Value]) { |
| 116 | match *self { |
| 117 | Self::Leaf { |
| 118 | size, |
| 119 | ref keys, |
| 120 | ref vals, |
| 121 | } => { |
| 122 | let size = usize::from(size); |
| 123 | let keys = keys.borrow(); |
| 124 | let vals = vals.borrow(); |
| 125 | // TODO: We could probably use `get_unchecked()` here since `size` is always in |
| 126 | // range. |
| 127 | (&keys[0..size], &vals[0..size]) |
| 128 | } |
| 129 | _ => panic!("Expected leaf node"), |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | /// Unwrap a mutable leaf node into two slices (keys, values) of the same length. |
| 134 | pub fn unwrap_leaf_mut(&mut self) -> (&mut [F::Key], &mut [F::Value]) { |