Skip to content

Commit

Permalink
Add missing methods on IResult<I,O,E>
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 8, 2016
1 parent a265060 commit 1b714b5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum IResult<I,O,E=u32> {
Incomplete(Needed)
}

impl<I,O> IResult<I,O> {
impl<I,O,E> IResult<I,O,E> {
pub fn is_done(&self) -> bool {
match *self {
Done(_,_) => true,
Expand All @@ -55,14 +55,14 @@ impl<I,O> IResult<I,O> {
}

pub fn is_err(&self) -> bool {
match *self {
match self {
Error(_) => true,
_ => false
}
}

pub fn is_incomplete(&self) -> bool {
match *self {
match self {
Incomplete(_) => true,
_ => false
}
Expand All @@ -77,7 +77,7 @@ pub trait GetOutput<O> {
fn output(&self) -> Option<O>;
}

impl<'a,I,O> GetInput<&'a[I]> for IResult<&'a[I],O> {
impl<'a,I,O,E> GetInput<&'a[I]> for IResult<&'a[I],O,E> {
fn remaining_input(&self) -> Option<&'a[I]> {
match *self {
Done(ref i,_) => Some(*i),
Expand All @@ -86,7 +86,7 @@ impl<'a,I,O> GetInput<&'a[I]> for IResult<&'a[I],O> {
}
}

impl<O> GetInput<()> for IResult<(),O> {
impl<O,E> GetInput<()> for IResult<(),O,E> {
fn remaining_input(&self) -> Option<()> {
match *self {
Done((),_) => Some(()),
Expand All @@ -95,7 +95,7 @@ impl<O> GetInput<()> for IResult<(),O> {
}
}

impl<'a,O> GetInput<&'a str> for IResult<&'a str,O> {
impl<'a,O,E> GetInput<&'a str> for IResult<&'a str,O,E> {
fn remaining_input(&self) -> Option<&'a str> {
match *self {
Done(ref i,_) => Some(*i),
Expand All @@ -104,7 +104,7 @@ impl<'a,O> GetInput<&'a str> for IResult<&'a str,O> {
}
}

impl<'a,I,O> GetOutput<&'a[O]> for IResult<I,&'a[O]> {
impl<'a,I,O,E> GetOutput<&'a[O]> for IResult<I,&'a[O],E> {
fn output(&self) -> Option<&'a[O]> {
match *self {
Done(_, ref o) => Some(*o),
Expand All @@ -113,7 +113,7 @@ impl<'a,I,O> GetOutput<&'a[O]> for IResult<I,&'a[O]> {
}
}

impl<I> GetOutput<()> for IResult<I,()> {
impl<I,E> GetOutput<()> for IResult<I,(),E> {
fn output(&self) -> Option<()> {
match *self {
Done(_,()) => Some(()),
Expand All @@ -122,7 +122,7 @@ impl<I> GetOutput<()> for IResult<I,()> {
}
}

impl<'a,I> GetOutput<&'a str> for IResult<I,&'a str> {
impl<'a,I,E> GetOutput<&'a str> for IResult<I,&'a str,E> {
fn output(&self) -> Option<&'a str> {
match *self {
Done(_,ref o) => Some(*o),
Expand Down

0 comments on commit 1b714b5

Please sign in to comment.