diff --git a/askama_parser/src/lib.rs b/askama_parser/src/lib.rs index ce1393f2..afe9968d 100644 --- a/askama_parser/src/lib.rs +++ b/askama_parser/src/lib.rs @@ -166,6 +166,22 @@ pub(crate) struct ErrorContext<'a> { pub(crate) message: Option>, } +impl<'a> ErrorContext<'a> { + pub(crate) fn from_err(error: nom::Err>) -> nom::Err { + match error { + nom::Err::Incomplete(i) => nom::Err::Incomplete(i), + nom::Err::Failure(Error { input, .. }) => nom::Err::Failure(Self { + input, + message: None, + }), + nom::Err::Error(Error { input, .. }) => nom::Err::Error(Self { + input, + message: None, + }), + } + } +} + impl<'a> nom::error::ParseError<&'a str> for ErrorContext<'a> { fn from_error_kind(input: &'a str, _code: ErrorKind) -> Self { Self { @@ -188,22 +204,6 @@ impl<'a, E: std::fmt::Display> FromExternalError<&'a str, E> for ErrorContext<'a } } -impl<'a> ErrorContext<'a> { - pub(crate) fn from_err(error: nom::Err>) -> nom::Err { - match error { - nom::Err::Incomplete(i) => nom::Err::Incomplete(i), - nom::Err::Failure(Error { input, .. }) => nom::Err::Failure(Self { - input, - message: None, - }), - nom::Err::Error(Error { input, .. }) => nom::Err::Error(Self { - input, - message: None, - }), - } - } -} - fn is_ws(c: char) -> bool { matches!(c, ' ' | '\t' | '\r' | '\n') }