mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 07:20:55 +00:00
parser: order inherent impl before trait impls
This commit is contained in:
parent
c1366e0fd8
commit
cbe8ac3c9e
@ -166,6 +166,22 @@ pub(crate) struct ErrorContext<'a> {
|
|||||||
pub(crate) message: Option<Cow<'static, str>>,
|
pub(crate) message: Option<Cow<'static, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ErrorContext<'a> {
|
||||||
|
pub(crate) fn from_err(error: nom::Err<Error<&'a str>>) -> nom::Err<Self> {
|
||||||
|
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> {
|
impl<'a> nom::error::ParseError<&'a str> for ErrorContext<'a> {
|
||||||
fn from_error_kind(input: &'a str, _code: ErrorKind) -> Self {
|
fn from_error_kind(input: &'a str, _code: ErrorKind) -> Self {
|
||||||
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<Error<&'a str>>) -> nom::Err<Self> {
|
|
||||||
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 {
|
fn is_ws(c: char) -> bool {
|
||||||
matches!(c, ' ' | '\t' | '\r' | '\n')
|
matches!(c, ' ' | '\t' | '\r' | '\n')
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user