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

Commit ebc5f21

Browse files
authored
Merge pull request #11 from mkmik/doc
Some docstrings for the matcher module
2 parents 8bdfd5a + ff39699 commit ebc5f21

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/matchers.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ use std::iter;
1010
/// An iterator over matcher selection results.
1111
type Iter<'a> = Box<dyn Iterator<Item = &'a Value> + 'a>;
1212

13-
// Matcher maps a node to a list of nodes. If the input node is not matched by the matcher or
14-
// the matcher does not select any subnodes of the input node, then the result is empty.
13+
/// Matcher maps a node to a list of nodes. If the input node is not matched by the matcher or
14+
/// the matcher does not select any subnodes of the input node, then the result is empty.
1515
pub trait Matcher {
1616
fn select<'a>(&'a self, node: &'a Value) -> Iter<'a>;
1717
}
1818

19+
/// Selects exactly one item, namely the node
20+
/// of the subtree the selector is applied to.
21+
///
22+
/// (which may or may be not the actual root of the document).
1923
pub struct RootSelector {}
2024

2125
impl Matcher for RootSelector {
@@ -24,6 +28,7 @@ impl Matcher for RootSelector {
2428
}
2529
}
2630

31+
/// Selects all children of a node.
2732
pub struct WildcardedChild {}
2833

2934
impl Matcher for WildcardedChild {
@@ -36,6 +41,7 @@ impl Matcher for WildcardedChild {
3641
}
3742
}
3843

44+
/// Selects a named child.
3945
pub struct Child {
4046
name: String,
4147
}
@@ -52,6 +58,8 @@ impl Matcher for Child {
5258
}
5359
}
5460

61+
/// Applies a sequence of selectors on the same node and returns
62+
/// a concatenation of the results.
5563
pub struct Union {
5664
elements: Vec<Box<dyn Matcher>>,
5765
}

0 commit comments

Comments
 (0)