Treat Symbols more uniformly like Strings

This commit is contained in:
Tony Garnock-Jones 2021-08-08 18:04:33 -04:00
parent 7abd4a3d3a
commit 02420543f1
1 changed files with 9 additions and 8 deletions

View File

@ -175,7 +175,7 @@ impl Step for AxisStep {
}
}
path::Axis::At { key } => match value.value() {
Value::String(s) =>
Value::String(s) | Value::Symbol(s) =>
step_index(path.step(value), s.chars(), &key, |c| IOValue::new(String::from(c)), &mut self.step),
Value::Record(r) =>
step_index(path.step(value), r.fields().iter(), &key, |v| v.clone(), &mut self.step),
@ -192,9 +192,9 @@ impl Step for AxisStep {
self.step.accept(path.step(value), r.label())
},
path::Axis::Keys => match value.value() {
Value::String(s) => step_keys(path.step(value), s.len(), &mut self.step),
Value::String(s) | Value::Symbol(s) =>
step_keys(path.step(value), s.len(), &mut self.step),
Value::ByteString(bs) => step_keys(path.step(value), bs.len(), &mut self.step),
Value::Symbol(s) => step_keys(path.step(value), s.len(), &mut self.step),
Value::Record(r) => step_keys(path.step(value), r.arity(), &mut self.step),
Value::Sequence(vs) => step_keys(path.step(value), vs.len(), &mut self.step),
Value::Dictionary(d) => {
@ -206,9 +206,9 @@ impl Step for AxisStep {
_ => (),
},
path::Axis::Length => match value.value() {
Value::String(s) => self.step.accept(path.step(value), &IOValue::new(s.len())),
Value::String(s) | Value::Symbol(s) =>
self.step.accept(path.step(value), &IOValue::new(s.len())),
Value::ByteString(bs) => self.step.accept(path.step(value), &IOValue::new(bs.len())),
Value::Symbol(s) => self.step.accept(path.step(value), &IOValue::new(s.len())),
Value::Record(r) => self.step.accept(path.step(value), &IOValue::new(r.arity())),
Value::Sequence(vs) => self.step.accept(path.step(value), &IOValue::new(vs.len())),
Value::Dictionary(d) => self.step.accept(path.step(value), &IOValue::new(d.len())),
@ -304,9 +304,10 @@ impl Step for CompareStep {
impl Step for RegexStep {
fn accept(&mut self, path: Rc<Path>, value: &IOValue) {
match value.value() {
Value::String(s) => if self.regex.is_match(s) { self.step.accept(path, value) },
Value::Symbol(s) => if self.regex.is_match(s) { self.step.accept(path, value) },
_ => (),
Value::String(s) | Value::Symbol(s) =>
if self.regex.is_match(s) { self.step.accept(path, value) },
_ =>
(),
}
}