diff --git a/src/formatter/parser.rs b/src/formatter/parser.rs index 929a037f..f393cb8b 100644 --- a/src/formatter/parser.rs +++ b/src/formatter/parser.rs @@ -7,50 +7,50 @@ use super::model::*; #[grammar = "formatter/spec.pest"] struct IdentParser; -fn _parse_value(value: Pair) -> FormatElement { +fn parse_value(value: Pair) -> FormatElement { match value.as_rule() { - Rule::text => FormatElement::Text(_parse_text(value).into()), - Rule::variable => FormatElement::Variable(_parse_variable(value).into()), - Rule::textgroup => FormatElement::TextGroup(_parse_textgroup(value)), + Rule::text => FormatElement::Text(parse_text(value).into()), + Rule::variable => FormatElement::Variable(parse_variable(value).into()), + Rule::textgroup => FormatElement::TextGroup(parse_textgroup(value)), Rule::conditional => { - FormatElement::Conditional(_parse_format(value.into_inner().next().unwrap())) + FormatElement::Conditional(parse_format(value.into_inner().next().unwrap())) } _ => unreachable!(), } } -fn _parse_textgroup(textgroup: Pair) -> TextGroup { +fn parse_textgroup(textgroup: Pair) -> TextGroup { let mut inner_rules = textgroup.into_inner(); let format = inner_rules.next().unwrap(); let style = inner_rules.next().unwrap(); TextGroup { - format: _parse_format(format), - style: _parse_style(style), + format: parse_format(format), + style: parse_style(style), } } -fn _parse_variable(variable: Pair) -> &str { +fn parse_variable(variable: Pair) -> &str { variable.into_inner().next().unwrap().as_str() } -fn _parse_text(text: Pair) -> String { +fn parse_text(text: Pair) -> String { text.into_inner() .map(|pair| pair.as_str().chars()) .flatten() .collect() } -fn _parse_format(format: Pair) -> Vec { - format.into_inner().map(_parse_value).collect() +fn parse_format(format: Pair) -> Vec { + format.into_inner().map(parse_value).collect() } -fn _parse_style(style: Pair) -> Vec { +fn parse_style(style: Pair) -> Vec { style .into_inner() .map(|pair| match pair.as_rule() { Rule::string => StyleElement::Text(pair.as_str().into()), - Rule::variable => StyleElement::Variable(_parse_variable(pair).into()), + Rule::variable => StyleElement::Variable(parse_variable(pair).into()), _ => unreachable!(), }) .collect() @@ -60,7 +60,7 @@ pub fn parse(format: &str) -> Result, Error> { IdentParser::parse(Rule::expression, format).map(|pairs| { pairs .take_while(|pair| pair.as_rule() != Rule::EOI) - .map(_parse_value) + .map(parse_value) .collect() }) } diff --git a/src/formatter/string_formatter.rs b/src/formatter/string_formatter.rs index 2cc9fdb3..7db1c853 100644 --- a/src/formatter/string_formatter.rs +++ b/src/formatter/string_formatter.rs @@ -204,13 +204,13 @@ impl<'a> StringFormatter<'a> { /// - Format string in meta variables fails to parse /// - Variable mapper returns an error. pub fn parse(self, default_style: Option