|
|
@ -102,10 +102,6 @@ impl ParseError<&str> for XsdParseError { |
|
|
|
fn or(self, other: Self) -> Self { |
|
|
|
fn or(self, other: Self) -> Self { |
|
|
|
other |
|
|
|
other |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn add_context(_input: &str, _ctx: &'static str, other: Self) -> Self { |
|
|
|
|
|
|
|
other |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl From<ParseIntError> for XsdParseError { |
|
|
|
impl From<ParseIntError> for XsdParseError { |
|
|
@ -150,7 +146,7 @@ const OVERFLOW_ERROR: XsdParseError = XsdParseError { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
pub fn parse_value<'a, T>( |
|
|
|
pub fn parse_value<'a, T>( |
|
|
|
f: impl Fn(&'a str) -> XsdResult<'a, T>, |
|
|
|
mut f: impl FnMut(&'a str) -> XsdResult<'a, T>, |
|
|
|
input: &'a str, |
|
|
|
input: &'a str, |
|
|
|
) -> Result<T, XsdParseError> { |
|
|
|
) -> Result<T, XsdParseError> { |
|
|
|
let (left, result) = f(input)?; |
|
|
|
let (left, result) = f(input)?; |
|
|
@ -533,9 +529,9 @@ fn parsed_u8_range(input: &str, min: u8, max: u8) -> Result<u8, XsdParseError> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn map_res<'a, O1, O2, E2: Into<XsdParseError>>( |
|
|
|
pub fn map_res<'a, O1, O2, E2: Into<XsdParseError>>( |
|
|
|
first: impl Fn(&'a str) -> XsdResult<'a, O1>, |
|
|
|
mut first: impl FnMut(&'a str) -> XsdResult<'a, O1>, |
|
|
|
second: impl Fn(O1) -> Result<O2, E2>, |
|
|
|
mut second: impl FnMut(O1) -> Result<O2, E2>, |
|
|
|
) -> impl Fn(&'a str) -> XsdResult<'a, O2> { |
|
|
|
) -> impl FnMut(&'a str) -> XsdResult<'a, O2> { |
|
|
|
move |input| { |
|
|
|
move |input| { |
|
|
|
let (input, o1) = first(input)?; |
|
|
|
let (input, o1) = first(input)?; |
|
|
|
Ok((input, second(o1).map_err(|e| Err::Error(e.into()))?)) |
|
|
|
Ok((input, second(o1).map_err(|e| Err::Error(e.into()))?)) |
|
|
|