Add TreeMap::remove_between that can take abstract start and end points
This commit introduces a new adaptor trait for SeekTarget that works around frustrating issues with lifetimes. It wraps the arguments in a newtype wrapper that lives on the stack to avoid the lifetime getting extended to the caller of the method. This allows us to introduce a PathSuccessor object that can be passed as the end argument of remove_between to remove a whole subtree.
This commit is contained in:
parent
89352a2bdc
commit
ee3637216e
3 changed files with 94 additions and 114 deletions
|
@ -54,7 +54,7 @@ use std::{
|
|||
},
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
use sum_tree::{Bias, Edit, SeekTarget, SumTree, TreeMap, TreeSet};
|
||||
use sum_tree::{Bias, Edit, SeekTarget, SumTree, TreeMap, TreeSet, PathDescendants};
|
||||
use util::{paths::HOME, ResultExt, TakeUntilExt, TryFutureExt};
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)]
|
||||
|
@ -3023,9 +3023,7 @@ impl BackgroundScanner {
|
|||
snapshot.repository_entries.update(&work_dir, |entry| {
|
||||
entry
|
||||
.worktree_statuses
|
||||
.remove_by(&repo_path, |stored_path| {
|
||||
stored_path.starts_with(&repo_path)
|
||||
})
|
||||
.remove_range(&repo_path, &PathDescendants(&repo_path))
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue