From 03a6203550bdd6f23f572376198c994e4880590b Mon Sep 17 00:00:00 2001 From: Glyn Normington Date: Mon, 1 Aug 2022 11:50:45 +0100 Subject: [PATCH] Rename Iter to NodeList --- src/ast.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index 6624884..14679e7 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -63,10 +63,11 @@ pub enum UnionElement { Index(i64), } -type Iter<'a> = Box + 'a>; +// NodeList is an iterator over references to Values named after the Nodelist term in the spec. +type NodeList<'a> = Box + 'a>; impl Path { - pub fn find<'a>(&'a self, input: &'a Value) -> Iter<'a> { + pub fn find<'a>(&'a self, input: &'a Value) -> NodeList<'a> { match self { Path::Root => Box::new(std::iter::once(input)), Path::Sel(left, sel) => Box::new(left.find(input).flat_map(move |v| sel.find(v))), @@ -75,7 +76,7 @@ impl Path { } impl Selector { - pub fn find<'a>(&'a self, input: &'a Value) -> Iter<'a> { + pub fn find<'a>(&'a self, input: &'a Value) -> NodeList<'a> { match self { Selector::Union(indices) => Box::new(indices.iter().flat_map(move |i| i.find(input))), Selector::DotName(name) => Box::new(input.get(name).into_iter()), @@ -89,7 +90,7 @@ impl Selector { } impl UnionElement { - pub fn find<'a>(&self, v: &'a Value) -> Iter<'a> { + pub fn find<'a>(&self, v: &'a Value) -> NodeList<'a> { match self { UnionElement::Name(name) => Box::new(v.get(name).into_iter()), UnionElement::Slice(slice) => {