pub struct PrunedSet { /* private fields */ }Expand description
Tracks paths already claimed by a rule, so nested candidates are not walked or re-reported.
This wrapper encapsulates the RefCell<HashSet<PathBuf>> to ensure borrow/borrow_mut
operations are temporary and cannot overlap.
Implementations§
Source§impl PrunedSet
impl PrunedSet
Sourcepub fn is_already_claimed(&self, path: &Path) -> bool
pub fn is_already_claimed(&self, path: &Path) -> bool
Whether this path overlaps a candidate that has already been reported.
Reporting both a directory and something inside it would count the nested bytes twice in the total and race the two deletions against each other. Rules within a directory are applied in order, so the overlap can be found in either direction: a nested target may be claimed before the parent enclosing it, or after.
Candidates stream to the user as they are found, so the first claim stands and the overlapping one is dropped. That can leave an enclosing directory unreclaimed, which is the safe direction to err for a tool that deletes things.
Returns true if:
- Any ancestor of
pathis in the pruned set (path is inside a claimed directory) - Any path in the pruned set starts with
path(path is a parent of something claimed)