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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
use crate::process::traversal::TraversalBuilder; use crate::structure::{GValue, Pop}; pub struct SelectStep { params: Vec<GValue>, } impl SelectStep { fn new(params: Vec<GValue>) -> Self { SelectStep { params } } } impl From<SelectStep> for Vec<GValue> { fn from(step: SelectStep) -> Self { step.params } } impl From<&str> for SelectStep { fn from(param: &str) -> SelectStep { SelectStep::new(vec![String::from(param).into()]) } } impl From<Pop> for SelectStep { fn from(param: Pop) -> SelectStep { SelectStep::new(vec![GValue::Pop(param)]) } } impl From<Vec<&str>> for SelectStep { fn from(param: Vec<&str>) -> SelectStep { SelectStep::new(param.into_iter().map(GValue::from).collect()) } } impl From<TraversalBuilder> for SelectStep { fn from(param: TraversalBuilder) -> SelectStep { SelectStep::new(vec![param.bytecode.into()]) } } impl<B> From<(Pop, B)> for SelectStep where B: Into<GValue>, { fn from(param: (Pop, B)) -> SelectStep { SelectStep::new(vec![GValue::Pop(param.0), param.1.into()]) } } macro_rules! impl_into_select { ($n:expr) => { impl<T: Clone> From<[T; $n]> for SelectStep where T: Into<String>, { fn from(param: [T; $n]) -> SelectStep { SelectStep::new(param.iter().map(|e| e.clone().into().into()).collect()) } } }; } impl_into_select!(1); impl_into_select!(2); impl_into_select!(3); impl_into_select!(4); impl_into_select!(5); impl_into_select!(6); impl_into_select!(7); impl_into_select!(8); impl_into_select!(9); impl_into_select!(10);