macro_rules! impl_box_clone {
($trait:ident, $clone_trait:ident) => {
pub trait $clone_trait {
fn clone_box(&self) -> Box<dyn $trait>;
}
impl<T> $clone_trait for T
where
T: $trait + Clone,
{
fn clone_box(&self) -> Box<dyn $trait> {
Box::new(self.clone())
}
}
impl Clone for Box<dyn $trait> {
fn clone(&self) -> Box<dyn $trait> {
self.clone_box()
}
}
};
}
pub(crate) use impl_box_clone;
#[allow(unused_macros)]
#[macro_export]
macro_rules! type_row {
() => {
{
$crate::types::TypeRow::new()
}
};
($($t:expr),+ $(,)?) => {
{
use $crate::types;
static ROW: &[types::Type] = &[$($t),*];
let row: types::TypeRow = ROW.into();
row
}
};
($t:expr; $n:expr) => {
{
use $crate::types;
static ROW: &[types::Type] = &[$t; $n];
let row: types::TypeRow = ROW.into();
row
}
};
}
#[allow(unused_imports)]
pub use type_row;
#[macro_export]
macro_rules! const_extension_ids {
($($(#[$attr:meta])* $v:vis const $field_name:ident : ExtensionId = $ext_name:expr;)+) => {
$($(#[$attr])* $v const $field_name: $crate::extension::ExtensionId =
$crate::extension::ExtensionId::new_unchecked($ext_name);
pastey::paste! {
#[test]
fn [<check_ $field_name:lower _wellformed>]() {
$crate::extension::ExtensionId::new($ext_name).unwrap();
}
})*
};
}
pub use const_extension_ids;
#[cfg(test)]
#[macro_export]
macro_rules! test_file {
($fname:expr) => {
concat!(env!("CARGO_MANIFEST_DIR"), "/resources/test/", $fname)
};
}