add derive Register macro

This commit is contained in:
steven-omaha
2023-01-12 23:07:27 +01:00
parent 0b4b45ed73
commit b5d58e6656
9 changed files with 189 additions and 47 deletions
-31
View File
@@ -41,34 +41,3 @@ macro_rules! impl_backend_constants {
}
};
}
#[macro_export]
macro_rules! register_backends {
($first:ident, $($name:ident),*) => {
#[derive(Debug)]
pub(crate) enum Backends {
$first,
$(
$name,
)*
}
impl Backends {
pub fn iter() -> BackendIter {
BackendIter {
next: Some(Backends::$first),
}
}
fn get_backend(&self) -> Box<dyn Backend> {
match self {
Self::$first => Box::new($first::new()),
$(
Self::$name => Box::new($name::new()),
)*
}
}
}
}
}