half-finish backend macro

i cannot figure out how procedural macros work actually
This commit is contained in:
steven-omaha
2023-01-12 15:01:04 +01:00
parent 49aa2b67e2
commit 1b4a4d8117
2 changed files with 6 additions and 56 deletions
-41
View File
@@ -42,39 +42,6 @@ macro_rules! impl_backend_constants {
};
}
// #[macro_export]
// macro_rules! register_backends {
// ($first:ident, $($name:ident),*) => {
// #[derive(Debug, Hash, PartialEq, Eq)]
// pub(crate) enum Backends {
// $first,
// $(
// $name,
// )*
// }
//
// impl Backends {
// pub fn iter() -> BackendIter {
// BackendIter {
// next: Some(Backends::$first),
// }
// }
// fn next(&self) -> Option<Self> {
// match self {
// $(
// Self::$name => match $name {
// $(
// _ => Some(Self::$name),
// )*
// _ => None
// },
// )*
// }
// }
// }
// }
// }
#[macro_export]
macro_rules! register_backends {
($first:ident, $($name:ident),*) => {
@@ -93,14 +60,6 @@ macro_rules! register_backends {
}
}
fn next(&self) -> Option<Self> {
println!("Some({:?})", Self::$first);
$(
println!("{:?}", Self::$name);
)*
None
}
fn get_backend(&self) -> Box<dyn Backend> {
match self {
Self::$first => Box::new($first::new()),
+6 -15
View File
@@ -23,21 +23,12 @@ pub(crate) use rust::Rust;
register_backends!(Pacman, Rust);
impl Backends {
// fn next(&self) -> Option<Self> {
// match self {
// Self::Pacman => Some(Self::Rust),
// Self::Rust => Some(Self::Pip),
// Self::Pip => None,
// }
// }
// fn get_backend(&self) -> Box<dyn Backend> {
// match self {
// Self::Pacman => Box::new(Pacman::new()),
// Self::Rust => Box::new(Rust::new()),
// _ => todo!(),
// }
// }
fn next(&self) -> Option<Self> {
match self {
Self::Pacman => Some(Self::Rust),
Self::Rust => None,
}
}
}
#[derive(Debug)]