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
use crate::process::traversal::Scope; use crate::structure::GValue; pub struct LimitStep { limit: GValue, scope: Option<Scope>, } impl LimitStep { fn new(limit: GValue, scope: Option<Scope>) -> Self { LimitStep { limit, scope } } } impl LimitStep { pub fn params(self) -> Vec<GValue> { let mut params = self .scope .map(|m| match m { Scope::Global => vec![String::from("Global").into()], Scope::Local => vec![String::from("Local").into()], }) .unwrap_or_else(|| vec![]); params.push(self.limit); params } } impl Into<LimitStep> for i64 { fn into(self) -> LimitStep { LimitStep::new(self.into(), None) } }