racme/src/macros.rs

36 Zeilen
833 B
Rust

use macro_rules_attribute::derive_alias;
#[allow(unused_macros)]
macro_rules! match_error {
($result:expr =>Err($errorname:ident)-> $errormessage:literal $(, $returntype:expr)?) => {
match $result {
Ok(ok) => ok,
Err($errorname) => {
::log::error!($errormessage);
return $($returntype)*;
},
}
};
}
#[allow(unused_macros)]
macro_rules! attr_function {
(
$visibility:vis $attr:ident $($items:ident).* => $type:ty
)=>{
$visibility fn $attr(&self) -> $type {
self$(.$items).*.$attr.clone()
}
}
}
derive_alias! {
#[derive(DefDer!)] = #[derive(Debug, Clone)];
#[derive(Hashable!)] = #[derive(Eq, Hash)];
}
#[allow(unused_imports)]
pub(crate) use {
attr_function,
match_error,
};