@@ -46,29 +46,26 @@ fn parse_child_name(matcher_rule: pest::iterators::Pair<Rule>) -> String {
46
46
}
47
47
48
48
fn parse_union_indices ( matcher_rule : pest:: iterators:: Pair < Rule > ) -> Vec < UnionElement > {
49
- let mut res = Vec :: new ( ) ;
50
-
51
- for r in matcher_rule. into_inner ( ) {
52
- match r. as_rule ( ) {
53
- Rule :: unionChild => res. append ( & mut parse_union_child ( r) ) ,
54
- Rule :: unionArrayIndex => res. push ( parse_union_array_index ( r) ) ,
55
- _ => panic ! ( "invalid parse tree {:?}" , r) ,
56
- }
57
- }
58
- res
59
- }
60
-
61
- fn parse_union_child ( matcher_rule : pest:: iterators:: Pair < Rule > ) -> Vec < UnionElement > {
62
49
matcher_rule
63
50
. into_inner ( )
64
51
. map ( |r| match r. as_rule ( ) {
65
- Rule :: doubleInner => UnionElement :: Name ( unescape ( r . as_str ( ) ) ) ,
66
- Rule :: singleInner => UnionElement :: Name ( unescape_single ( r . as_str ( ) ) ) ,
52
+ Rule :: unionChild => parse_union_child ( r ) ,
53
+ Rule :: unionArrayIndex => parse_union_array_index ( r ) ,
67
54
_ => panic ! ( "invalid parse tree {:?}" , r) ,
68
55
} )
69
56
. collect ( )
70
57
}
71
58
59
+ fn parse_union_child ( matcher_rule : pest:: iterators:: Pair < Rule > ) -> UnionElement {
60
+ let r = matcher_rule. into_inner ( ) . next ( ) . unwrap ( ) ;
61
+
62
+ UnionElement :: Name ( match r. as_rule ( ) {
63
+ Rule :: doubleInner => unescape ( r. as_str ( ) ) ,
64
+ Rule :: singleInner => unescape_single ( r. as_str ( ) ) ,
65
+ _ => panic ! ( "invalid parse tree {:?}" , r) ,
66
+ } )
67
+ }
68
+
72
69
fn parse_union_array_index ( matcher_rule : pest:: iterators:: Pair < Rule > ) -> UnionElement {
73
70
let i = matcher_rule. as_str ( ) . parse ( ) . unwrap ( ) ;
74
71
UnionElement :: Index ( i)
0 commit comments