From f925b56b6b82bc6de052c93d08005db09536796b Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 18 Oct 2024 15:53:57 -0700 Subject: [PATCH] ResolveUniqueNameOpts: Make `directory_names` borrowed (#44) It doesn't need to be owned! --- src/git/worktree/resolve_unique_names.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/git/worktree/resolve_unique_names.rs b/src/git/worktree/resolve_unique_names.rs index 1bacc0c..51245ae 100644 --- a/src/git/worktree/resolve_unique_names.rs +++ b/src/git/worktree/resolve_unique_names.rs @@ -23,7 +23,7 @@ pub struct ResolveUniqueNameOpts<'a> { /// /// This is used to prevent worktree paths like `my-repo/my-repo` for detached `HEAD` /// worktrees. - pub directory_names: &'a HashSet, + pub directory_names: &'a HashSet<&'a str>, } /// When we convert a repository into a worktree checkout, we put all the worktrees in one @@ -122,11 +122,11 @@ pub struct RenamedWorktree { struct WorktreeNames<'a> { git: &'a Git, worktree: &'a Worktree, - directory_names: &'a HashSet, + directory_names: &'a HashSet<&'a str>, } impl<'a> WorktreeNames<'a> { - fn new(git: &'a Git, worktree: &'a Worktree, directory_names: &'a HashSet) -> Self { + fn new(git: &'a Git, worktree: &'a Worktree, directory_names: &'a HashSet<&'a str>) -> Self { Self { git, worktree, @@ -239,11 +239,7 @@ mod tests { ResolveUniqueNameOpts { worktrees, names: self.names.into_iter().map(|name| name.to_owned()).collect(), - directory_names: &self - .directory_names - .into_iter() - .map(|name| name.to_owned()) - .collect(), + directory_names: &self.directory_names.into_iter().collect(), }, ) .unwrap()