From 2a76f2dde6533c09f8e93b44d1f214a105d9c5c2 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Thu, 28 Dec 2023 15:29:19 +0100 Subject: Format (#38) --- parser/src/pair_ext_parse.rs | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'parser/src/pair_ext_parse.rs') diff --git a/parser/src/pair_ext_parse.rs b/parser/src/pair_ext_parse.rs index fb5ba6b..cbb51b0 100644 --- a/parser/src/pair_ext_parse.rs +++ b/parser/src/pair_ext_parse.rs @@ -1,21 +1,41 @@ use std::str::FromStr; -use pest::Span; +use pest::error::{Error, ErrorVariant}; use pest::iterators::Pair; -use pest::error::{Error,ErrorVariant}; - +use pest::Span; -pub trait PairExt where R: pest::RuleType { - fn parse(&self) -> Result>> where T: FromStr, E: ToString; +pub trait PairExt +where + R: pest::RuleType, +{ + fn parse(&self) -> Result>> + where + T: FromStr, + E: ToString; } -impl<'l, R> PairExt for Pair<'l, R> where R: pest::RuleType { - fn parse(&self) -> Result>> where T: FromStr, E: ToString { - self.as_str().parse().map_err(|e| to_parse_error(self.as_span(), &e)) - } +impl<'l, R> PairExt for Pair<'l, R> +where + R: pest::RuleType, +{ + fn parse(&self) -> Result>> + where + T: FromStr, + E: ToString, + { + self.as_str() + .parse() + .map_err(|e| to_parse_error(self.as_span(), &e)) + } } -pub(crate) fn to_parse_error(span: Span, e: &E) -> Box> where E: ToString, R: pest::RuleType { - let var: ErrorVariant = ErrorVariant::CustomError { message: e.to_string() }; - Box::new(Error::new_from_span(var, span)) +pub(crate) fn to_parse_error(span: Span, e: &E) -> Box> +where + E: ToString, + R: pest::RuleType, +{ + let var: ErrorVariant = ErrorVariant::CustomError { + message: e.to_string(), + }; + Box::new(Error::new_from_span(var, span)) } -- cgit v1.2.3