diff --git a/src/matchers.rs b/src/matchers.rs index 835e321..ab3190c 100644 --- a/src/matchers.rs +++ b/src/matchers.rs @@ -37,8 +37,10 @@ pub struct Child { name: String, } -pub fn new_child_matcher(name: String) -> Child { - Child { name } +impl Child { + pub fn new(name: String) -> Self { + Child { name } + } } impl Matcher for Child { @@ -51,8 +53,10 @@ pub struct Union { elements: Vec>, } -pub fn new_union(elements: Vec>) -> Union { - Union { elements } +impl Union { + pub fn new(elements: Vec>) -> Self { + Union { elements } + } } impl Matcher for Union { diff --git a/src/parser.rs b/src/parser.rs index aef543c..626a23c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -66,7 +66,7 @@ fn parse_dot_child_matcher( let mut ms: Vec> = Vec::new(); for r in matcher_rule.into_inner() { if let Rule::childName = r.as_rule() { - ms.push(Box::new(matchers::new_child_matcher(r.as_str().to_owned()))); + ms.push(Box::new(matchers::Child::new(r.as_str().to_owned()))); } } ms @@ -81,7 +81,7 @@ fn parse_union(matcher_rule: pest::iterators::Pair) -> Vec) -> Vec> { @@ -89,11 +89,11 @@ fn parse_union_child(matcher_rule: pest::iterators::Pair) -> Vec { - ms.push(Box::new(matchers::new_child_matcher(unescape(r.as_str())))); + ms.push(Box::new(matchers::Child::new(unescape(r.as_str())))); } Rule::singleInner => { - ms.push(Box::new(matchers::new_child_matcher(unescape(r.as_str())))); + ms.push(Box::new(matchers::Child::new(unescape(r.as_str())))); } _ => (),