diff --git a/libs/utils/src/vec_map.rs b/libs/utils/src/vec_map.rs index 9953b447c8..66bc5d0c26 100644 --- a/libs/utils/src/vec_map.rs +++ b/libs/utils/src/vec_map.rs @@ -20,10 +20,22 @@ impl VecMap { self.0.is_empty() } + pub fn last(&self) -> Option<&(K, V)> { + self.0.last() + } + pub fn as_slice(&self) -> &[(K, V)] { self.0.as_slice() } + pub fn inner(self) -> Vec<(K, V)> { + self.0 + } + + pub fn len(&self) -> usize { + self.0.len() + } + /// This function may panic if given a range where the lower bound is /// greater than the upper bound. pub fn slice_range>(&self, range: R) -> &[(K, V)] { @@ -90,6 +102,10 @@ impl VecMap { Ok((None, delta_size)) } + pub fn truncate(&mut self, pos: usize) { + self.0.truncate(pos) + } + /// Split the map into two. /// /// The left map contains everything before `cutoff` (exclusive).