Switch from IResult to PResult in synom
diff --git a/synom/src/delimited.rs b/synom/src/delimited.rs
index 2cb0303..6735512 100644
--- a/synom/src/delimited.rs
+++ b/synom/src/delimited.rs
@@ -238,29 +238,24 @@
 
 #[cfg(feature = "parsing")]
 mod parsing {
-    use proc_macro2::TokenTree;
-
     use super::Delimited;
-    use {IResult, Synom};
+    use {PResult, Cursor, Synom, parse_error};
 
     impl<T, D> Delimited<T, D>
         where T: Synom,
               D: Synom,
     {
-        pub fn parse_separated(input: &[TokenTree])
-            -> IResult<&[TokenTree], Self>
+        pub fn parse_separated(input: Cursor) -> PResult<Self>
         {
             Self::parse(input, T::parse, false)
         }
 
-        pub fn parse_separated_nonempty(input: &[TokenTree])
-            -> IResult<&[TokenTree], Self>
+        pub fn parse_separated_nonempty(input: Cursor) -> PResult<Self>
         {
             Self::parse_separated_nonempty_with(input, T::parse)
         }
 
-        pub fn parse_terminated(input: &[TokenTree])
-            -> IResult<&[TokenTree], Self>
+        pub fn parse_terminated(input: Cursor) -> PResult<Self>
         {
             Self::parse_terminated_with(input, T::parse)
         }
@@ -270,49 +265,49 @@
         where D: Synom,
     {
         pub fn parse_separated_nonempty_with(
-                input: &[TokenTree],
-                parse: fn(&[TokenTree]) -> IResult<&[TokenTree], T>)
-            -> IResult<&[TokenTree], Self>
+                input: Cursor,
+                parse: fn(Cursor) -> PResult<T>)
+            -> PResult<Self>
         {
             match Self::parse(input, parse, false) {
-                IResult::Done(_, ref b) if b.is_empty() => IResult::Error,
+                Ok((_, ref b)) if b.is_empty() => parse_error(),
                 other => other,
             }
         }
 
         pub fn parse_terminated_with(
-                input: &[TokenTree],
-                parse: fn(&[TokenTree]) -> IResult<&[TokenTree], T>)
-            -> IResult<&[TokenTree], Self>
+                input: Cursor,
+                parse: fn(Cursor) -> PResult<T>)
+            -> PResult<Self>
         {
             Self::parse(input, parse, true)
         }
 
-        fn parse(mut input: &[TokenTree],
-                 parse: fn(&[TokenTree]) -> IResult<&[TokenTree], T>,
+        fn parse(mut input: Cursor,
+                 parse: fn(Cursor) -> PResult<T>,
                  terminated: bool)
-            -> IResult<&[TokenTree], Self>
+            -> PResult<Self>
         {
             let mut res = Delimited::new();
 
             // get the first element
             match parse(input) {
-                IResult::Error => IResult::Done(input, res),
-                IResult::Done(i, o) => {
+                Err(_) => Ok((input, res)),
+                Ok((i, o)) => {
                     if i.len() == input.len() {
-                        return IResult::Error
+                        return parse_error();
                     }
                     input = i;
                     res.push_first(o);
 
                     // get the separator first
-                    while let IResult::Done(i2, s) = D::parse(input) {
+                    while let Ok((i2, s)) = D::parse(input) {
                         if i2.len() == input.len() {
                             break;
                         }
 
                         // get the element next
-                        if let IResult::Done(i3, o3) = parse(i2) {
+                        if let Ok((i3, o3)) = parse(i2) {
                             if i3.len() == i2.len() {
                                 break;
                             }
@@ -323,12 +318,12 @@
                         }
                     }
                     if terminated {
-                        if let IResult::Done(after, sep) = D::parse(input) {
+                        if let Ok((after, sep)) = D::parse(input) {
                             res.push_trailing(sep);
                             input = after;
                         }
                     }
-                    IResult::Done(input, res)
+                    Ok((input, res))
                 }
             }
         }
diff --git a/synom/src/helper.rs b/synom/src/helper.rs
index b0bc7cf..d04b8ba 100644
--- a/synom/src/helper.rs
+++ b/synom/src/helper.rs
@@ -17,8 +17,10 @@
 macro_rules! option {
     ($i:expr, $submac:ident!( $($args:tt)* )) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Done(i, o) => $crate::IResult::Done(i, Some(o)),
-            $crate::IResult::Error => $crate::IResult::Done($i, None),
+            ::std::result::Result::Ok((i, o)) =>
+                ::std::result::Result::Ok((i, Some(o))),
+            ::std::result::Result::Err(_) =>
+                ::std::result::Result::Ok(($i, None)),
         }
     };
 
@@ -61,8 +63,10 @@
 macro_rules! opt_vec {
     ($i:expr, $submac:ident!( $($args:tt)* )) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Done(i, o) => $crate::IResult::Done(i, o),
-            $crate::IResult::Error => $crate::IResult::Done($i, Vec::new()),
+            ::std::result::Result::Ok((i, o)) =>
+                ::std::result::Result::Ok((i, o)),
+            ::std::result::Result::Err(_) =>
+                ::std::result::Result::Ok(($i, Vec::new()))
         }
     };
 }
@@ -91,7 +95,7 @@
 #[macro_export]
 macro_rules! epsilon {
     ($i:expr,) => {
-        $crate::IResult::Done($i, ())
+        ::std::result::Result::Ok(($i, ()))
     };
 }
 
@@ -132,12 +136,13 @@
 macro_rules! tap {
     ($i:expr, $name:ident : $submac:ident!( $($args:tt)* ) => $e:expr) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Done(i, o) => {
+            ::std::result::Result::Ok((i, o)) => {
                 let $name = o;
                 $e;
-                $crate::IResult::Done(i, ())
+                ::std::result::Result::Ok((i, ()))
             }
-            $crate::IResult::Error => $crate::IResult::Error,
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
         }
     };
 
diff --git a/synom/src/lib.rs b/synom/src/lib.rs
index c5e364b..89571b8 100644
--- a/synom/src/lib.rs
+++ b/synom/src/lib.rs
@@ -1,5 +1,5 @@
 //! Adapted from [`nom`](https://github.com/Geal/nom) by removing the
-//! `IResult::Incomplete` variant which:
+//! `IPResult::Incomplete` variant which:
 //!
 //! - we don't need,
 //! - is an unintuitive footgun when working with non-streaming use cases, and
@@ -44,35 +44,24 @@
 pub mod tokens;
 pub mod span;
 
-/// The result of a parser.
-#[derive(Debug, PartialEq, Eq, Clone)]
-pub enum IResult<I, O> {
-    /// Parsing succeeded. The first field contains the rest of the unparsed
-    /// data and the second field contains the parse result.
-    Done(I, O),
-    /// Parsing failed.
-    Error,
-}
+/// A cursor into a Vec<TokenTree>.
+///
+/// NOTE: This type is currently unnecessary, but will make future refactorings
+/// which change this type easier.
+pub type Cursor<'a> = &'a [TokenTree];
 
-impl<'a, O> IResult<&'a [TokenTree], O> {
-    /// Unwraps the result, asserting the the parse is complete. Panics with a
-    /// message based on the given string if the parse failed or is incomplete.
-    pub fn expect(self, name: &str) -> O {
-        match self {
-            IResult::Done(rest, o) => {
-                if rest.is_empty() {
-                    o
-                } else {
-                    panic!("unparsed tokens after {}: {:?}", name, /* rest */ ())
-                }
-            }
-            IResult::Error => panic!("failed to parse {}", name),
-        }
-    }
+/// The result of a parser
+pub type PResult<'a, O> = Result<(Cursor<'a>, O), ParseError>;
+
+/// An error with a default error message.
+///
+/// NOTE: We should provide better error messages in the future.
+pub fn parse_error<O>() -> PResult<'static, O> {
+    Err(ParseError("error parsing value".to_string()))
 }
 
 pub trait Synom: Sized {
-    fn parse(input: &[TokenTree]) -> IResult<&[TokenTree], Self>;
+    fn parse(input: Cursor) -> PResult<Self>;
 
     fn description() -> Option<&'static str> {
         None
@@ -81,7 +70,7 @@
     fn parse_all(input: TokenStream) -> Result<Self, ParseError> {
         let tokens = input.into_iter().collect::<Vec<_>>();
         let err = match Self::parse(&tokens) {
-            IResult::Done(rest, t) => {
+            Ok((rest, t)) => {
                 if rest.is_empty() {
                     return Ok(t)
                 } else if rest.len() == tokens.len() {
@@ -91,7 +80,7 @@
                     "unparsed tokens after"
                 }
             }
-            IResult::Error => "failed to parse"
+            Err(_) => "failed to parse"
         };
         match Self::description() {
             Some(s) => Err(ParseError(format!("{} {}", err, s))),
@@ -133,8 +122,8 @@
 }
 
 impl Synom for TokenStream {
-    fn parse(input: &[TokenTree]) -> IResult<&[TokenTree], Self> {
-        IResult::Done(&[], input.iter().cloned().collect())
+    fn parse(input: &[TokenTree]) -> PResult<Self> {
+        Ok((&[], input.iter().cloned().collect()))
     }
 }
 
@@ -157,13 +146,13 @@
 #[macro_export]
 macro_rules! named {
     ($name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => {
-        fn $name(i: &[$crate::TokenTree]) -> $crate::IResult<&[$crate::TokenTree], $o> {
+        fn $name(i: $crate::Cursor) -> $crate::PResult<$o> {
             $submac!(i, $($args)*)
         }
     };
 
     (pub $name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => {
-        pub fn $name(i: &[$crate::TokenTree]) -> $crate::IResult<&[$crate::TokenTree], $o> {
+        pub fn $name(i: $crate::Cursor) -> $crate::PResult<$o> {
             $submac!(i, $($args)*)
         }
     };
@@ -173,7 +162,7 @@
 ///
 /// - **Syntax:** `call!(FUNCTION, ARGS...)`
 ///
-///   where the signature of the function is `fn(&[U], ARGS...) -> IResult<&[U], T>`
+///   where the signature of the function is `fn(&[U], ARGS...) -> IPResult<&[U], T>`
 /// - **Output:** `T`, the result of invoking the function `FUNCTION`
 #[macro_export]
 macro_rules! call {
@@ -213,10 +202,10 @@
 macro_rules! map {
     ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Error => $crate::IResult::Error,
-            $crate::IResult::Done(i, o) => {
-                $crate::IResult::Done(i, call!(o, $g))
-            }
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
+            ::std::result::Result::Ok((i, o)) =>
+                ::std::result::Result::Ok((i, call!(o, $g))),
         }
     };
 
@@ -234,8 +223,9 @@
 macro_rules! not {
     ($i:expr, $submac:ident!( $($args:tt)* )) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Done(_, _) => $crate::IResult::Error,
-            $crate::IResult::Error => $crate::IResult::Done($i, ()),
+            ::std::result::Result::Ok(_) => $crate::parse_error(),
+            ::std::result::Result::Err(_) =>
+                ::std::result::Result::Ok(($i, ())),
         }
     };
 }
@@ -251,11 +241,12 @@
     ($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => {
         if $cond {
             match $submac!($i, $($args)*) {
-                $crate::IResult::Done(i, o) => $crate::IResult::Done(i, ::std::option::Option::Some(o)),
-                $crate::IResult::Error => $crate::IResult::Error,
+                ::std::result::Result::Ok((i, o)) =>
+                    ::std::result::Result::Ok((i, ::std::option::Option::Some(o))),
+                ::std::result::Result::Err(x) => ::std::result::Result::Err(x),
             }
         } else {
-            $crate::IResult::Done($i, ::std::option::Option::None)
+            ::std::result::Result::Ok(($i, ::std::option::Option::None))
         }
     };
 
@@ -276,7 +267,7 @@
         if $cond {
             $submac!($i, $($args)*)
         } else {
-            $crate::IResult::Error
+            $crate::parse_error()
         }
     };
 
@@ -308,8 +299,10 @@
 macro_rules! terminated {
     ($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => {
         match tuple!($i, $submac!($($args)*), $submac2!($($args2)*)) {
-            $crate::IResult::Done(remaining, (o, _)) => $crate::IResult::Done(remaining, o),
-            $crate::IResult::Error => $crate::IResult::Error,
+            ::std::result::Result::Ok((i, (o, _))) =>
+                ::std::result::Result::Ok((i, o)),
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
         }
     };
 
@@ -355,19 +348,19 @@
 
         loop {
             if input.is_empty() {
-                ret = $crate::IResult::Done(input, res);
+                ret = ::std::result::Result::Ok((input, res));
                 break;
             }
 
             match $submac!(input, $($args)*) {
-                $crate::IResult::Error => {
-                    ret = $crate::IResult::Done(input, res);
+                ::std::result::Result::Err(_) => {
+                    ret = ::std::result::Result::Ok((input, res));
                     break;
                 }
-                $crate::IResult::Done(i, o) => {
+                ::std::result::Result::Ok((i, o)) => {
                     // loop trip must always consume (otherwise infinite loops)
                     if i.len() == input.len() {
-                        ret = $crate::IResult::Error;
+                        ret = $crate::parse_error();
                         break;
                     }
 
@@ -390,24 +383,22 @@
 //
 // Not public API.
 #[doc(hidden)]
-pub fn many0<'a, T>(mut input: &'a [TokenTree],
-                    f: fn(&'a [TokenTree]) -> IResult<&'a [TokenTree], T>)
-                    -> IResult<&'a [TokenTree], Vec<T>> {
+pub fn many0<'a, T>(mut input: Cursor, f: fn(Cursor) -> PResult<T>) -> PResult<Vec<T>> {
     let mut res = Vec::new();
 
     loop {
         if input.is_empty() {
-            return IResult::Done(input, res);
+            return Ok((input, res));
         }
 
         match f(input) {
-            IResult::Error => {
-                return IResult::Done(input, res);
+            Err(_) => {
+                return Ok((input, res));
             }
-            IResult::Done(i, o) => {
+            Ok((i, o)) => {
                 // loop trip must always consume (otherwise infinite loops)
                 if i.len() == input.len() {
-                    return IResult::Error;
+                    return parse_error();
                 }
 
                 res.push(o);
@@ -427,7 +418,6 @@
 /// #[macro_use] extern crate synom;
 ///
 /// use syn::{Expr, Ident};
-/// use synom::IResult;
 ///
 /// // Parse an expression that begins with an identifier.
 /// named!(ident_expr -> (Ident, Expr),
@@ -440,8 +430,8 @@
 macro_rules! peek {
     ($i:expr, $submac:ident!( $($args:tt)* )) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Done(_, o) => $crate::IResult::Done($i, o),
-            $crate::IResult::Error => $crate::IResult::Error,
+            ::std::result::Result::Ok((_, o)) => ::std::result::Result::Ok(($i, o)),
+            ::std::result::Result::Err(err) => ::std::result::Result::Err(err),
         }
     };
 
@@ -506,12 +496,12 @@
 macro_rules! switch {
     ($i:expr, $submac:ident!( $($args:tt)* ), $($p:pat => $subrule:ident!( $($args2:tt)* ))|* ) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Error => $crate::IResult::Error,
-            $crate::IResult::Done(i, o) => match o {
+            ::std::result::Result::Err(err) => ::std::result::Result::Err(err),
+            ::std::result::Result::Ok((i, o)) => match o {
                 $(
                     $p => $subrule!(i, $($args2)*),
                 )*
-                _ => $crate::IResult::Error,
+                _ => $crate::parse_error(),
             }
         }
     };
@@ -574,7 +564,7 @@
 #[macro_export]
 macro_rules! value {
     ($i:expr, $res:expr) => {
-        $crate::IResult::Done($i, $res)
+        ::std::result::Result::Ok(($i, $res))
     };
 }
 
@@ -610,16 +600,18 @@
 
     ($i:expr, (), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Error => $crate::IResult::Error,
-            $crate::IResult::Done(i, o) =>
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
+            ::std::result::Result::Ok((i, o)) =>
                 tuple_parser!(i, (o), $($rest)*),
         }
     };
 
     ($i:expr, ($($parsed:tt)*), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Error => $crate::IResult::Error,
-            $crate::IResult::Done(i, o) =>
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
+            ::std::result::Result::Ok((i, o)) =>
                 tuple_parser!(i, ($($parsed)* , o), $($rest)*),
         }
     };
@@ -634,13 +626,15 @@
 
     ($i:expr, ($($parsed:expr),*), $submac:ident!( $($args:tt)* )) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Error => $crate::IResult::Error,
-            $crate::IResult::Done(i, o) => $crate::IResult::Done(i, ($($parsed),*, o))
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
+            ::std::result::Result::Ok((i, o)) =>
+                ::std::result::Result::Ok((i, ($($parsed),*, o))),
         }
     };
 
     ($i:expr, ($($parsed:expr),*)) => {
-        $crate::IResult::Done($i, ($($parsed),*))
+        ::std::result::Result::Ok(($i, ($($parsed),*)))
     };
 }
 
@@ -677,15 +671,16 @@
 
     ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => {
         match $subrule!($i, $($args)*) {
-            res @ $crate::IResult::Done(_, _) => res,
+            res @ ::std::result::Result::Ok(_) => res,
             _ => alt!($i, $($rest)*)
         }
     };
 
     ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => {
         match $subrule!($i, $($args)*) {
-            $crate::IResult::Done(i, o) => $crate::IResult::Done(i, $gen(o)),
-            $crate::IResult::Error => alt!($i, $($rest)*)
+            ::std::result::Result::Ok((i, o)) =>
+                ::std::result::Result::Ok((i, $gen(o))),
+            ::std::result::Result::Err(_) => alt!($i, $($rest)*),
         }
     };
 
@@ -699,8 +694,10 @@
 
     ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => {
         match $subrule!($i, $($args)*) {
-            $crate::IResult::Done(i, o) => $crate::IResult::Done(i, $gen(o)),
-            $crate::IResult::Error => $crate::IResult::Error,
+            ::std::result::Result::Ok((i, o)) =>
+                ::std::result::Result::Ok((i, $gen(o))),
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
         }
     };
 
@@ -744,7 +741,7 @@
 #[macro_export]
 macro_rules! do_parse {
     ($i:expr, ( $($rest:expr),* )) => {
-        $crate::IResult::Done($i, ( $($rest),* ))
+        ::std::result::Result::Ok(($i, ( $($rest),* )))
     };
 
     ($i:expr, $e:ident >> $($rest:tt)*) => {
@@ -753,8 +750,9 @@
 
     ($i:expr, $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Error => $crate::IResult::Error,
-            $crate::IResult::Done(i, _) =>
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
+            ::std::result::Result::Ok((i, _)) =>
                 do_parse!(i, $($rest)*),
         }
     };
@@ -765,8 +763,9 @@
 
     ($i:expr, $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Error => $crate::IResult::Error,
-            $crate::IResult::Done(i, o) => {
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
+            ::std::result::Result::Ok((i, o)) => {
                 let $field = o;
                 do_parse!(i, $($rest)*)
             },
@@ -779,8 +778,9 @@
 
     ($i:expr, mut $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => {
         match $submac!($i, $($args)*) {
-            $crate::IResult::Error => $crate::IResult::Error,
-            $crate::IResult::Done(i, o) => {
+            ::std::result::Result::Err(err) =>
+                ::std::result::Result::Err(err),
+            ::std::result::Result::Ok((i, o)) => {
                 let mut $field = o;
                 do_parse!(i, $($rest)*)
             },
@@ -797,10 +797,10 @@
 
 // Not a public API
 #[doc(hidden)]
-pub fn input_end(input: &[TokenTree]) -> IResult<&'static [TokenTree], &'static str> {
+pub fn input_end(input: Cursor) -> PResult<'static, &'static str> {
     if input.is_empty() {
-        IResult::Done(&[], "")
+        Ok((&[], ""))
     } else {
-        IResult::Error
+        parse_error()
     }
 }
diff --git a/synom/src/tokens.rs b/synom/src/tokens.rs
index 595019d..5e06e3f 100644
--- a/synom/src/tokens.rs
+++ b/synom/src/tokens.rs
@@ -41,9 +41,7 @@
 
         #[cfg(feature = "parsing")]
         impl ::Synom for $name {
-            fn parse(tokens: &[::proc_macro2::TokenTree])
-                -> ::IResult<&[::proc_macro2::TokenTree], $name>
-            {
+            fn parse(tokens: $crate::Cursor) -> $crate::PResult<$name> {
                 parsing::op($s, tokens, $name)
             }
         }
@@ -66,9 +64,7 @@
 
         #[cfg(feature = "parsing")]
         impl ::Synom for $name {
-            fn parse(tokens: &[::proc_macro2::TokenTree])
-                -> ::IResult<&[::proc_macro2::TokenTree], $name>
-            {
+            fn parse(tokens: $crate::Cursor) -> $crate::PResult<$name> {
                 parsing::sym($s, tokens, $name)
             }
         }
@@ -93,10 +89,8 @@
             }
 
             #[cfg(feature = "parsing")]
-            pub fn parse<F, R>(tokens: &[::proc_macro2::TokenTree], f: F)
-                -> ::IResult<&[::proc_macro2::TokenTree], (R, $name)>
-                where F: FnOnce(&[::proc_macro2::TokenTree])
-                            -> ::IResult<&[::proc_macro2::TokenTree], R>
+            pub fn parse<F, R>(tokens: $crate::Cursor, f: F) -> $crate::PResult<(R, $name)>
+                where F: FnOnce($crate::Cursor) -> $crate::PResult<R>
             {
                 parsing::delim($s, tokens, $name, f)
             }
@@ -201,7 +195,7 @@
 mod parsing {
     use proc_macro2::{TokenTree, TokenKind, Delimiter, OpKind};
 
-    use IResult;
+    use {PResult, Cursor, parse_error};
     use span::Span;
 
     pub trait FromSpans: Sized {
@@ -227,9 +221,9 @@
     }
 
     pub fn op<'a, T, R>(s: &str,
-                        tokens: &'a [TokenTree],
+                        tokens: Cursor<'a>,
                         new: fn(T) -> R)
-            -> IResult<&'a [TokenTree], R>
+            -> PResult<'a, R>
         where T: FromSpans,
     {
         let mut spans = [Span::default(); 3];
@@ -240,46 +234,46 @@
         for (i, (ch, slot)) in chars.zip(&mut spans).enumerate() {
             let tok = match it.next() {
                 Some(tok) => tok,
-                _ => return IResult::Error
+                _ => return parse_error(),
             };
             let kind = match tok.kind {
                 TokenKind::Op(c, kind) if c == ch => kind,
-                _ => return IResult::Error
+                _ => return parse_error(),
             };
             if i != s.len() - 1 {
                 match kind {
                     OpKind::Joint => {}
-                    OpKind::Alone => return IResult::Error,
+                    OpKind::Alone => return parse_error(),
                 }
             }
             *slot = Span(tok.span);
         }
-        IResult::Done(it.as_slice(), new(T::from_spans(&spans)))
+        Ok((it.as_slice(), new(T::from_spans(&spans))))
     }
 
     pub fn sym<'a, T>(sym: &str,
-                      tokens: &'a [TokenTree],
+                      tokens: Cursor<'a>,
                       new: fn(Span) -> T)
-        -> IResult<&'a [TokenTree], T>
+        -> PResult<'a, T>
     {
         let mut tokens = tokens.iter();
         let (span, s) = match tokens.next() {
             Some(&TokenTree { span, kind: TokenKind::Word(sym) }) => (span, sym),
-            _ => return IResult::Error,
+            _ => return parse_error(),
         };
         if s.as_str() == sym {
-            IResult::Done(tokens.as_slice(), new(Span(span)))
+            Ok((tokens.as_slice(), new(Span(span))))
         } else {
-            IResult::Error
+            parse_error()
         }
     }
 
     pub fn delim<'a, F, R, T>(delim: &str,
-                              tokens: &'a [TokenTree],
+                              tokens: Cursor<'a>,
                               new: fn(Span) -> T,
                               f: F)
-        -> ::IResult<&'a [TokenTree], (R, T)>
-        where F: FnOnce(&[TokenTree]) -> IResult<&[TokenTree], R>
+        -> PResult<'a, (R, T)>
+        where F: FnOnce(Cursor) -> PResult<R>
     {
         let delim = match delim {
             "(" => Delimiter::Parenthesis,
@@ -292,27 +286,27 @@
             Some(&TokenTree { span, kind: TokenKind::Sequence(d, ref rest) }) => {
                 (span, d, rest)
             }
-            _ => return IResult::Error,
+            _ => return parse_error(),
         };
         match (delim, d) {
             (Delimiter::Parenthesis, Delimiter::Parenthesis) |
             (Delimiter::Brace, Delimiter::Brace) |
             (Delimiter::Bracket, Delimiter::Bracket) => {}
-            _ => return IResult::Error,
+            _ => return parse_error(),
         }
 
         // TODO: Need a custom type to avoid this allocation every time we try
-        // this branch
+        // this branch. (issue dtolnay/syn#148)
         let rest = others.clone().into_iter().collect::<Vec<_>>();
         match f(&rest) {
-            IResult::Done(remaining, ret) => {
+            Ok((remaining, ret)) => {
                 if remaining.is_empty() {
-                    IResult::Done(tokens.as_slice(), (ret, new(Span(span))))
+                    Ok((tokens.as_slice(), (ret, new(Span(span)))))
                 } else {
-                    IResult::Error
+                    parse_error()
                 }
             }
-            IResult::Error => IResult::Error,
+            Err(err) => Err(err),
         }
     }
 }