Skip to content

Commit

Permalink
refactor: Inline backend match block
Browse files Browse the repository at this point in the history
  • Loading branch information
IshanGrover2004 committed Jan 21, 2024
1 parent 142e701 commit 61902f4
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/blocks/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,22 +280,17 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
.transpose()
.error("invalid ignore updates regex")?;

let mut package_manager_vec = Vec::new();
let mut package_manager_vec: Vec<Box<dyn Backend>> = Vec::new();

for &package_manager in config.package_manager.iter() {
let backend = match package_manager {
PackageManager::Apt => {
Box::new(Apt::new(config.ignore_phased_updates).await?) as Box<dyn Backend>
}
PackageManager::Pacman => Box::new(Pacman::new().await?) as Box<dyn Backend>,
package_manager_vec.push(match package_manager {
PackageManager::Apt => Box::new(Apt::new(config.ignore_phased_updates).await?),
PackageManager::Pacman => Box::new(Pacman::new().await?),
PackageManager::Aur => {
Box::new(Aur::new(config.aur_command.clone().unwrap_or_default()))
as Box<dyn Backend>
}
PackageManager::Dnf => Box::new(Dnf::new()) as Box<dyn Backend>,
};

package_manager_vec.push(backend);
PackageManager::Dnf => Box::new(Dnf::new()),
});
}

loop {
Expand Down

0 comments on commit 61902f4

Please sign in to comment.