diff --git a/src/rule/collection/index.rs b/src/rule/collection/index.rs index 80c43a5..f44205b 100644 --- a/src/rule/collection/index.rs +++ b/src/rule/collection/index.rs @@ -1,38 +1,37 @@ -use std::collections::VecDeque; - use crate::rule::Rule; #[macro_export] macro_rules! define_index_refined { - ($lit:literal) => { + (($vis:vis, $lit:expr)) => { $crate::paste::item! { - pub type [] = $crate::Refined<[]>; + $vis type [] = $crate::Refined<[]>; - pub type [] = $crate::Refined<[]>; + $vis type [] = $crate::Refined<[]>; - pub type [] = $crate::Refined<[]>; + $vis type [] = $crate::Refined<[]>; - pub type [] = $crate::Refined<[]>; + $vis type [] = $crate::Refined<[]>; } }; - ($lit:literal, $($lits:literal),*) => { - define_index_refined!($lit); - define_index_refined!($($lits),*); - } + ($(($vis:vis, $lit:expr)),*) => { + $( + $crate::define_index_refined!(($vis, $lit)); + )* + }; } #[macro_export] macro_rules! define_index_rule { - ($lit:literal) => { + (($vis:vis, $lit:expr)) => { $crate::paste::item! { - pub struct [] + $vis struct [] where RULE: $crate::rule::Rule, { _phantom_data: ::std::marker::PhantomData<(RULE, ITERABLE)>, } - pub type [] = []::Item>>; + $vis type [] = []::Item>>; impl $crate::rule::Rule for []> where RULE: $crate::rule::Rule { type Item = Vec; @@ -56,7 +55,7 @@ macro_rules! define_index_rule { } } - pub type [] = []::Item>>; + $vis type [] = []::Item>>; impl $crate::rule::Rule for []> where RULE: $crate::rule::Rule { type Item = ::std::collections::VecDeque; @@ -78,7 +77,7 @@ macro_rules! define_index_rule { } } - pub type [] = []; + $vis type [] = []; impl $crate::rule::Rule for [] where RULE: $crate::rule::Rule { type Item = String; @@ -114,19 +113,19 @@ macro_rules! define_index_rule { } } }; - ($lit:literal, $($lits:literal),*) => { - define_index_rule!($lit); - define_index_rule!($($lits),*); - } + ($(($vis:vis, $lit:expr)),*) => { + $( + $crate::define_index_rule!(($vis, $lit)); + )* + }; } // define index refined type for 0 ~ 10 by default. // if you want to define additional refined index types, you can add more using `define_index_refined`. -define_index_refined!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - +define_index_refined!((pub, 0), (pub, 1), (pub, 2), (pub, 3), (pub, 4), (pub, 5), (pub, 6), (pub, 7), (pub, 8), (pub, 9), (pub, 10)); // define index rules for 0 ~ 10 by default // if you want to define additional index rules, you can add more using `define_index_rule`. -define_index_rule!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); +define_index_rule!((pub, 0), (pub, 1), (pub, 2), (pub, 3), (pub, 4), (pub, 5), (pub, 6), (pub, 7), (pub, 8), (pub, 9), (pub, 10)); #[cfg(test)] mod tests {