diff --git a/src/cli/edit_command.rs b/src/cli/edit_command.rs index caa43a1..d2dd61e 100644 --- a/src/cli/edit_command.rs +++ b/src/cli/edit_command.rs @@ -75,7 +75,7 @@ pub struct Edit { impl LprsCommand for Edit { fn run(self, mut vault_manager: Vaults) -> LprsResult<()> { - let vault = match utils::vault_by_index_or_name(self.location, &mut vault_manager.vaults) { + let vault = match utils::vault_by_index_or_name(&self.location, &mut vault_manager.vaults) { Ok((_, v)) => v, Err(err) => { if self.force { diff --git a/src/cli/get_command.rs b/src/cli/get_command.rs index 93d5498..641f040 100644 --- a/src/cli/get_command.rs +++ b/src/cli/get_command.rs @@ -112,7 +112,7 @@ pub struct Get { impl LprsCommand for Get { fn run(self, mut vault_manager: Vaults) -> LprsResult<()> { let (index, vault) = - utils::vault_by_index_or_name(self.location, &mut vault_manager.vaults)?; + utils::vault_by_index_or_name(&self.location, &mut vault_manager.vaults)?; if let Some(field) = self.field { if field == VaultGetField::Index { diff --git a/src/utils.rs b/src/utils.rs index 84c504d..944dfd9 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -244,16 +244,17 @@ pub fn prompt_custom( /// /// ## Errors /// - If there is no vault with the given index or name -pub fn vault_by_index_or_name( - location: Either, - vaults: &mut [Vault], -) -> LprsResult<(usize, &mut Vault)> { +pub fn vault_by_index_or_name<'v>( + location: &Either, + vaults: &'v mut [Vault], +) -> LprsResult<(usize, &'v mut Vault)> { let idx = location + .as_ref() .map_right(|name| { vaults .iter() .enumerate() - .find_map(|(idx, v)| (v.name == name).then_some(idx)) + .find_map(|(idx, v)| (&v.name == name).then_some(idx)) .ok_or_else(|| { LprsError::Other(format!("There is no vault with the given name `{name}`")) })