Skip to content

Commit

Permalink
ResolveUniqueNameOpts: Make directory_names borrowed (#44)
Browse files Browse the repository at this point in the history
It doesn't need to be owned!
  • Loading branch information
9999years authored Oct 18, 2024
1 parent 729317d commit f925b56
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/git/worktree/resolve_unique_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub directory_names: &'a HashSet<&'a str>,
}

/// When we convert a repository into a worktree checkout, we put all the worktrees in one
Expand Down Expand Up @@ -122,11 +122,11 @@ pub struct RenamedWorktree {
struct WorktreeNames<'a> {
git: &'a Git,
worktree: &'a Worktree,
directory_names: &'a HashSet<String>,
directory_names: &'a HashSet<&'a str>,
}

impl<'a> WorktreeNames<'a> {
fn new(git: &'a Git, worktree: &'a Worktree, directory_names: &'a HashSet<String>) -> Self {
fn new(git: &'a Git, worktree: &'a Worktree, directory_names: &'a HashSet<&'a str>) -> Self {
Self {
git,
worktree,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f925b56

Please sign in to comment.