Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Rename Iter to NodeList #32

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ pub enum UnionElement {
Index(i64),
}

type Iter<'a> = Box<dyn Iterator<Item = &'a Value> + 'a>;
// NodeList is an iterator over references to Values named after the Nodelist term in the spec.
type NodeList<'a> = Box<dyn Iterator<Item = &'a Value> + '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))),
Expand All @@ -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()),
Expand All @@ -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) => {
Expand Down