Reference instead of passing the vector

This commit is contained in:
Jeevitha Kannan K S 2024-11-11 08:00:03 +05:30
parent 7e96651bbe
commit 35159b8393
No known key found for this signature in database
GPG Key ID: 5904C34A2F7CE333
2 changed files with 3 additions and 3 deletions

View File

@ -21,7 +21,7 @@ pub struct ConfirmPrompt {
} }
impl ConfirmPrompt { impl ConfirmPrompt {
pub fn new(names: Vec<&str>) -> Self { pub fn new(names: &[&str]) -> Self {
let names = names let names = names
.iter() .iter()
.zip(1..) .zip(1..)

View File

@ -137,7 +137,7 @@ impl AppState {
.map(|node| node.name.as_str()) .map(|node| node.name.as_str())
.collect(); .collect();
let prompt = ConfirmPrompt::new(cmd_names); let prompt = ConfirmPrompt::new(&cmd_names);
self.focus = Focus::ConfirmationPrompt(Float::new(Box::new(prompt), 40, 40)); self.focus = Focus::ConfirmationPrompt(Float::new(Box::new(prompt), 40, 40));
} }
} }
@ -798,7 +798,7 @@ impl AppState {
.map(|node| node.name.as_str()) .map(|node| node.name.as_str())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let prompt = ConfirmPrompt::new(cmd_names); let prompt = ConfirmPrompt::new(&cmd_names);
self.focus = Focus::ConfirmationPrompt(Float::new(Box::new(prompt), 40, 40)); self.focus = Focus::ConfirmationPrompt(Float::new(Box::new(prompt), 40, 40));
} }
} }