Allow guests to rename stuff

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-05-04 10:27:04 -07:00
parent 470d693d5e
commit 438e4e7a19
7 changed files with 113 additions and 29 deletions

View file

@ -502,6 +502,23 @@ impl<T: KeyedItem> SumTree<T> {
replaced
}
pub fn remove(&mut self, key: &T::Key, cx: &<T::Summary as Summary>::Context) -> Option<T> {
let mut removed = None;
*self = {
let mut cursor = self.cursor::<T::Key>();
let mut new_tree = cursor.slice(key, Bias::Left, cx);
if let Some(item) = cursor.item() {
if item.key() == *key {
removed = Some(item.clone());
cursor.next(cx);
}
}
new_tree.push_tree(cursor.suffix(cx), cx);
new_tree
};
removed
}
pub fn edit(
&mut self,
mut edits: Vec<Edit<T>>,