chore: impl some error conversions

This commit is contained in:
Shunsuke Shibayama 2023-11-03 17:40:56 +09:00
parent 8a793c7d59
commit ed0f8e1d57
2 changed files with 18 additions and 0 deletions

View file

@ -609,6 +609,12 @@ impl ParserRunnerError {
}
}
impl From<ParserRunnerError> for LexError {
fn from(err: ParserRunnerError) -> Self {
Self::new(err.core)
}
}
#[derive(Debug)]
pub struct ParserRunnerErrors(Vec<ParserRunnerError>);
@ -618,6 +624,12 @@ impl_stream!(ParserRunnerErrors, ParserRunnerError);
impl MultiErrorDisplay<ParserRunnerError> for ParserRunnerErrors {}
impl From<ParserRunnerErrors> for LexErrors {
fn from(errs: ParserRunnerErrors) -> Self {
Self(errs.0.into_iter().map(LexError::from).collect())
}
}
impl fmt::Display for ParserRunnerErrors {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.fmt_all(f)