array range with step

This commit is contained in:
freestrings
2019-06-17 18:05:02 +09:00
parent 51deec66d0
commit 74666d264e
4 changed files with 114 additions and 34 deletions

View File

@ -933,7 +933,7 @@ impl<'a, 'b> NodeVisitor for Selector<'a, 'b> {
unreachable!()
}
}
ParseToken::Range(from, to) => {
ParseToken::Range(from, to, step) => {
if !self.terms.is_empty() {
unimplemented!("range syntax in filter");
}
@ -955,7 +955,10 @@ impl<'a, 'b> NodeVisitor for Selector<'a, 'b> {
vec.len()
};
for i in from..to {
for i in (from..to).step_by(match step {
Some(step) => *step,
_ => 1
}) {
if let Some(v) = vec.get(i) {
tmp.push(v);
}