1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::error;
use std::fmt;
use parser;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Error<'input> {
Parser(parser::Error<'input>),
MoreInput,
}
impl<'input> fmt::Display for Error<'input> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
use self::Error::*;
match *self {
Parser(ref p) => write!(fmt, "parser error: {}", p),
MoreInput => write!(fmt, "more input"),
}
}
}
impl<'input> error::Error for Error<'input> {
fn description(&self) -> &str {
use self::Error::*;
match *self {
Parser(ref p) => p.description(),
MoreInput => "more input",
}
}
}
impl<'input> From<parser::Error<'input>> for Error<'input> {
fn from(value: parser::Error<'input>) -> Self {
Error::Parser(value)
}
}