From 86674c3fa11e31f3a4ebd0364e003c6370ed8fdd Mon Sep 17 00:00:00 2001 From: timeshifter Date: Mon, 9 Jan 2023 17:26:03 +0100 Subject: [PATCH] combine impls of Backends --- src/backend/mod.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 9deed76..1e1a013 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -10,8 +10,8 @@ use crate::Package; pub use pacman::Pacman; pub use rust::Rust; -pub type Switches = &'static [&'static str]; -pub type Text = &'static str; +pub(in crate::backend) type Switches = &'static [&'static str]; +pub(in crate::backend) type Text = &'static str; #[derive(Debug)] pub enum Backends { @@ -23,6 +23,17 @@ impl Backends { pub fn iter() -> BackendIter { BackendIter(Some(Self::Pacman)) } + + pub fn get(&self) -> Box { + match self { + Self::Pacman => Box::new(Pacman { + packages: HashSet::new(), + }), + Self::Rust => Box::new(Rust { + packages: HashSet::new(), + }), + } + } } pub struct BackendIter(Option); @@ -45,19 +56,6 @@ impl Iterator for BackendIter { } } -impl Backends { - pub fn get(&self) -> Box { - match self { - Self::Pacman => Box::new(Pacman { - packages: HashSet::new(), - }), - Self::Rust => Box::new(Rust { - packages: HashSet::new(), - }), - } - } -} - pub trait Backend { fn get_binary(&self) -> Text; fn get_section(&self) -> Text;