combine impls of Backends
This commit is contained in:
+13
-15
@@ -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<dyn Backend> {
|
||||
match self {
|
||||
Self::Pacman => Box::new(Pacman {
|
||||
packages: HashSet::new(),
|
||||
}),
|
||||
Self::Rust => Box::new(Rust {
|
||||
packages: HashSet::new(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BackendIter(Option<Backends>);
|
||||
@@ -45,19 +56,6 @@ impl Iterator for BackendIter {
|
||||
}
|
||||
}
|
||||
|
||||
impl Backends {
|
||||
pub fn get(&self) -> Box<dyn Backend> {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user