Implementing std::error::Error and Display for ParserError can make handling parser errors and notifying the user a bit easier. I had to implement my own logic for this, and matching on each ErrorKind variant can be annoying.
I'm not sure if we want the Display impl to just show the reason parsing failed (i.e. defer to the self.kind impl), or whether we also want to mention pos in the error message. I believe pos represents the index into the string and not line/column numbers, so it's not very useful for a human wanting to fix the parse error.
Implementing
std::error::Error
andDisplay
forParserError
can make handling parser errors and notifying the user a bit easier. I had to implement my own logic for this, and matching on eachErrorKind
variant can be annoying.I'm not sure if we want the
Display
impl to just show the reason parsing failed (i.e. defer to theself.kind
impl), or whether we also want to mentionpos
in the error message. I believepos
represents the index into the string and not line/column numbers, so it's not very useful for a human wanting to fix the parse error.