File size: 835 Bytes
bee6636 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
use std::{
collections::{HashMap, HashSet},
error::Error,
};
use oxc::allocator::Allocator;
pub type RewriteRuleCallback<T> = Box<
dyn for<'alloc, 'data> Fn(
&'alloc Allocator,
&'data str,
&'data T,
) -> Result<Option<&'alloc str>, Box<dyn Error + Sync + Send>>,
>;
pub struct RewriteRule<T> {
pub attrs: HashMap<String, Option<HashSet<String>>>,
pub func: RewriteRuleCallback<T>,
}
#[macro_export]
macro_rules! attrmap {
({
$($attr:literal: [$($el:literal),*]),*
}) => {
{
let mut map = std::collections::HashMap::<String, Option<std::collections::HashSet<String>>>::new();
$(
{
let mut vec = std::collections::HashSet::new();
$(
vec.insert($el.to_string());
)*
map.insert($attr.to_string(), Some(vec));
}
)*
map
}
};
}
|