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 42 43 44 45 46 47 48 49 50 51
use crate::process::traversal::TraversalBuilder; use crate::structure::GValue; pub struct MatchStep { params: Vec<GValue>, } impl MatchStep { fn new(params: Vec<GValue>) -> Self { MatchStep { params } } } impl From<MatchStep> for Vec<GValue> { fn from(step: MatchStep) -> Self { step.params } } impl From<TraversalBuilder> for MatchStep { fn from(param: TraversalBuilder) -> MatchStep { MatchStep::new(vec![param.bytecode.into()]) } } impl From<Vec<TraversalBuilder>> for MatchStep { fn from(param: Vec<TraversalBuilder>) -> MatchStep { MatchStep::new(param.into_iter().map(|s| s.bytecode.into()).collect()) } } macro_rules! impl_into_match { ($n:expr) => { impl From<[TraversalBuilder; $n]> for MatchStep { fn from(param: [TraversalBuilder; $n]) -> MatchStep { MatchStep::new(param.iter().map(|s| s.bytecode.clone().into()).collect()) } } }; } impl_into_match!(1); impl_into_match!(2); impl_into_match!(3); impl_into_match!(4); impl_into_match!(5); impl_into_match!(6); impl_into_match!(7); impl_into_match!(8); impl_into_match!(9); impl_into_match!(10);