@@ -10,12 +10,16 @@ use std::iter;
10
10
/// An iterator over matcher selection results.
11
11
type Iter < ' a > = Box < dyn Iterator < Item = & ' a Value > + ' a > ;
12
12
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.
15
15
pub trait Matcher {
16
16
fn select < ' a > ( & ' a self , node : & ' a Value ) -> Iter < ' a > ;
17
17
}
18
18
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).
19
23
pub struct RootSelector { }
20
24
21
25
impl Matcher for RootSelector {
@@ -24,6 +28,7 @@ impl Matcher for RootSelector {
24
28
}
25
29
}
26
30
31
+ /// Selects all children of a node.
27
32
pub struct WildcardedChild { }
28
33
29
34
impl Matcher for WildcardedChild {
@@ -36,6 +41,7 @@ impl Matcher for WildcardedChild {
36
41
}
37
42
}
38
43
44
+ /// Selects a named child.
39
45
pub struct Child {
40
46
name : String ,
41
47
}
@@ -52,6 +58,8 @@ impl Matcher for Child {
52
58
}
53
59
}
54
60
61
+ /// Applies a sequence of selectors on the same node and returns
62
+ /// a concatenation of the results.
55
63
pub struct Union {
56
64
elements : Vec < Box < dyn Matcher > > ,
57
65
}
0 commit comments