From fe1b0fd15491b86bd38e4801a6e5004f425bc0a3 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 3 Sep 2018 00:19:57 -0500 Subject: [PATCH] FEATURE: Require Debug be implemented for `err` in the `Error` struct. --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0f3d77b..efd5b42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ //! A parser combinator library with a focus on fully abortable parsing and error handling. -use std::fmt::Display; +use std::fmt::{Debug, Display}; use std::iter::Iterator; /// A trait for types that can have an offset as a count of processed items. @@ -20,13 +20,13 @@ pub trait InputIter: Iterator + Clone + Offsetable {} /// Stores a wrapped err that must implement Display as well as an offset and /// an optional cause. #[derive(Debug)] -pub struct Error { +pub struct Error { err: E, offset: usize, cause: Option>>, } -impl Error { +impl Error { /// Constructs a new Error with an offset and no cause. pub fn new(err: E, offset: &S) -> Self { Error { @@ -64,7 +64,7 @@ impl Error { } } -impl Display for Error { +impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> { try!(write!(f, "{}", self.err)); match self.cause { @@ -76,7 +76,7 @@ impl Display for Error { /// The result of a parsing attempt. #[derive(Debug)] -pub enum Result { +pub enum Result { /// Complete represents a successful match. Complete(I, O), /// Incomplete indicates input ended before a match could be completed. @@ -88,7 +88,7 @@ pub enum Result { Abort(Error), } -impl Result { +impl Result { /// Returns true if the Result is Complete. pub fn is_complete(&self) -> bool { if let &Result::Complete(_, _) = self {