Repository: Marwes/combine (language: rust)

Issue:
README: Update coveralls link/badge 
Used to point to parser-combinators still


Discussion / hints:
coveralls uploads has actually been broken for quite a while https://github.com/huonw/travis-cargo/issues/67. Will see if [this post](https://shaneutt.com/?p=72 or) may get it working again or I will just remove the badge.

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index 4aee1d8b..9f2cbf48 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,14 @@
 language: rust
+cache: cargo
 sudo: false
+dist: trusty
 addons:
   apt:
     packages:
     - libcurl4-openssl-dev
     - libelf-dev
     - libdw-dev
+    - libssl-dev
 rust:
 - nightly
 - beta
@@ -21,9 +24,11 @@ script:
   travis_wait cargo test &&
   travis-cargo --only nightly bench &&
   travis-cargo --only stable doc
-after_success:
-- travis-cargo --only stable doc-upload
-- travis-cargo coveralls --no-sudo
+after_success: |
+    if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then
+        cargo install cargo-tarpaulin
+        cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID
+    fi
 env:
   global:
   - TRAVIS_CARGO_NIGHTLY_FEATURE=""
diff --git a/src/byte.rs b/src/byte.rs
index 14e83e20..addc99d7 100644
--- a/src/byte.rs
+++ b/src/byte.rs
@@ -7,18 +7,14 @@ use self::ascii::AsciiChar;
 use combinator::{Expected, satisfy, Satisfy, skip_many, SkipMany, token, Token, tokens, With};
 use primitives::{ConsumedResult, Info, Parser, ParseError, Stream};
 
-/// Parses a character and succeeds if the character is equal to `c`.
+/// Parses a byteacter and succeeds if the byteacter is equal to `c`.
 ///
 /// ```
-/// # extern crate combine;
-/// # use combine::*;
-/// # use combine::byte::byte;
-/// # fn main() {
-/// let result = byte(b'!')
-///     .parse(&b"!"[..])
-///     .map(|x| x.0);
-/// assert_eq!(result, Ok(b'!'));
-/// # }
+/// use combine::Parser;
+/// use combine::byte::byte;
+/// assert_eq!(byte(b'!').parse(&b"!"[..]), Ok((b'!', &b""[..])));
+/// assert!(byte(b'A').parse(&b""[..]).is_err());
+/// assert!(byte(b'A').parse(&b"!"[..]).is_err());
 /// ```
 #[inline(always)]
 pub fn byte<I>(c: u8) -> Token<I>
@@ -40,6 +36,13 @@ macro_rules! byte_parser {
 }
 
 /// Parses a base-10 digit (0–9).
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::digit;
+/// assert_eq!(digit().parse(&b"9"[..]), Ok((b'9', &b""[..])));
+/// assert!(digit().parse(&b"A"[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn digit<I>() -> Digit<I>
 where
@@ -51,6 +54,15 @@ where
 impl_token_parser! { Space(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
 
 /// Parses a `b' '`, `b'\t'`, `b'\n'` or `'b\'r'`.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::space;
+/// assert_eq!(space().parse(&b" "[..]), Ok((b' ', &b""[..])));
+/// assert_eq!(space().parse(&b"  "[..]), Ok((b' ', &b" "[..])));
+/// assert!(space().parse(&b"!"[..]).is_err());
+/// assert!(space().parse(&b""[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn space<I>() -> Space<I>
 where
@@ -63,6 +75,13 @@ impl_token_parser! { Spaces(), u8, Expected<SkipMany<Space<I>>> }
 /// Skips over [`space`] zero or more times
 ///
 /// [`space`]: fn.space.html
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::spaces;
+/// assert_eq!(spaces().parse(&b""[..]), Ok(((), &b""[..])));
+/// assert_eq!(spaces().parse(&b"   "[..]), Ok(((), &b""[..])));
+/// ```
 #[inline(always)]
 pub fn spaces<I>() -> Spaces<I>
 where
@@ -73,7 +92,14 @@ where
 
 impl_token_parser! { Newline(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
 
-/// Parses a newline character (`b'\n'`).
+/// Parses a newline byteacter (`b'\n'`).
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::newline;
+/// assert_eq!(newline().parse(&b"\n"[..]), Ok((b'\n', &b""[..])));
+/// assert!(newline().parse(&b"\r"[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn newline<I>() -> Newline<I>
 where
@@ -87,7 +113,15 @@ where
 
 impl_token_parser! { CrLf(), u8, Expected<With<Satisfy<I, fn (u8) -> bool>, Newline<I>>> }
 
-/// Parses carriage return and newline (`b"\r\n"`), returning the newline character.
+/// Parses carriage return and newline (`&b"\r\n"`), returning the newline byteacter.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::crlf;
+/// assert_eq!(crlf().parse(&b"\r\n"[..]), Ok((b'\n', &b""[..])));
+/// assert!(crlf().parse(&b"\r"[..]).is_err());
+/// assert!(crlf().parse(&b"\n"[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn crlf<I>() -> CrLf<I>
 where
@@ -102,7 +136,14 @@ where
 }
 
 impl_token_parser! { Tab(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
-/// Parses a tab character (`b'\t'`).
+/// Parses a tab byteacter (`b'\t'`).
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::tab;
+/// assert_eq!(tab().parse(&b"\t"[..]), Ok((b'\t', &b""[..])));
+/// assert!(tab().parse(&b" "[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn tab<I>() -> Tab<I>
 where
@@ -116,6 +157,13 @@ where
 
 impl_token_parser! { Upper(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
 /// Parses an uppercase ASCII letter (A–Z).
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::upper;
+/// assert_eq!(upper().parse(&b"A"[..]), Ok((b'A', &b""[..])));
+/// assert!(upper().parse(&b"a"[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn upper<I>() -> Upper<I>
 where
@@ -126,6 +174,13 @@ where
 
 impl_token_parser! { Lower(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
 /// Parses an lowercase ASCII letter (a–z).
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::lower;
+/// assert_eq!(lower().parse(&b"a"[..]), Ok((b'a', &b""[..])));
+/// assert!(lower().parse(&b"A"[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn lower<I>() -> Lower<I>
 where
@@ -136,6 +191,14 @@ where
 
 impl_token_parser! { AlphaNum(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
 /// Parses either an ASCII alphabet letter or digit (a–z, A–Z, 0–9).
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::alpha_num;
+/// assert_eq!(alpha_num().parse(&b"A"[..]), Ok((b'A', &b""[..])));
+/// assert_eq!(alpha_num().parse(&b"1"[..]), Ok((b'1', &b""[..])));
+/// assert!(alpha_num().parse(&b"!"[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn alpha_num<I>() -> AlphaNum<I>
 where
@@ -146,6 +209,14 @@ where
 
 impl_token_parser! { Letter(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
 /// Parses an ASCII alphabet letter (a–z, A–Z).
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::letter;
+/// assert_eq!(letter().parse(&b"a"[..]), Ok((b'a', &b""[..])));
+/// assert_eq!(letter().parse(&b"A"[..]), Ok((b'A', &b""[..])));
+/// assert!(letter().parse(&b"9"[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn letter<I>() -> Letter<I>
 where
@@ -154,8 +225,36 @@ where
     byte_parser!(letter, Letter, is_alphabetic)
 }
 
+impl_token_parser! { OctDigit(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
+
+/// Parses an octal digit.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::oct_digit;
+/// assert_eq!(oct_digit().parse(&b"7"[..]), Ok((b'7', &b""[..])));
+/// assert!(oct_digit().parse(&b"8"[..]).is_err());
+/// ```
+#[inline(always)]
+pub fn oct_digit<I>() -> OctDigit<I>
+where
+    I: Stream<Item = u8>,
+{
+    OctDigit(
+        satisfy(static_fn!((ch, u8) -> bool { ch >= b'0' && ch <= b'7' })).expected("octal digit"),
+        PhantomData,
+    )
+}
+
 impl_token_parser! { HexDigit(), u8, Expected<Satisfy<I, fn (u8) -> bool>> }
 /// Parses an ASCII hexdecimal digit (accepts both uppercase and lowercase).
+///
+/// ```
+/// use combine::Parser;
+/// use combine::byte::hex_digit;
+/// assert_eq!(hex_digit().parse(&b"F"[..]), Ok((b'F', &b""[..])));
+/// assert!(hex_digit().parse(&b"H"[..]).is_err());
+/// ```
 #[inline(always)]
 pub fn hex_digit<I>() -> HexDigit<I>
 where
@@ -179,7 +278,7 @@ where
     fn parse_lazy(&mut self, input: Self::Input) -> ConsumedResult<Self::Output, Self::Input> {
         tokens(|&l, r| l == r, Info::Range(self.0), self.0.iter())
             .parse_lazy(input)
-            .map(|chars| chars.as_slice())
+            .map(|bytes| bytes.as_slice())
     }
     fn add_error(&mut self, errors: &mut ParseError<Self::Input>) {
         tokens(|&l, r| l == r, Info::Range(self.0), self.0.iter()).add_error(errors)
@@ -196,7 +295,7 @@ where
 /// # use combine::*;
 /// # use combine::byte::bytes;
 /// # fn main() {
-/// let result = bytes(b"rust")
+/// let result = bytes(&b"rust"[..])
 ///     .parse(&b"rust"[..])
 ///     .map(|x| x.0);
 /// assert_eq!(result, Ok(&b"rust"[..]));
diff --git a/src/char.rs b/src/char.rs
index 6ec98652..9b9b1c0e 100644
--- a/src/char.rs
+++ b/src/char.rs
@@ -5,15 +5,10 @@ use std::marker::PhantomData;
 /// Parses a character and succeeds if the character is equal to `c`.
 ///
 /// ```
-/// # extern crate combine;
-/// # use combine::*;
-/// # use combine::char::char;
-/// # fn main() {
-/// let result = char('!')
-///     .parse("!")
-///     .map(|x| x.0);
-/// assert_eq!(result, Ok('!'));
-/// # }
+/// use combine::Parser;
+/// use combine::char::char;
+/// assert_eq!(char('!').parse("!"), Ok(('!', "")));
+/// assert!(char('A').parse("!").is_err());
 /// ```
 #[inline(always)]
 pub fn char<I>(c: char) -> Token<I>
@@ -26,6 +21,13 @@ where
 impl_token_parser! { Digit(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 
 /// Parses a base-10 digit.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::digit;
+/// assert_eq!(digit().parse("9"), Ok(('9', "")));
+/// assert!(digit().parse("A").is_err());
+/// ```
 #[inline(always)]
 pub fn digit<I>() -> Digit<I>
 where
@@ -44,6 +46,15 @@ impl_token_parser! { Space(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 /// This includes space characters, tabs and newlines.
 ///
 /// [`std::char::is_whitespace`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_whitespace
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::space;
+/// assert_eq!(space().parse(" "), Ok((' ', "")));
+/// assert_eq!(space().parse("  "), Ok((' ', " ")));
+/// assert!(space().parse("!").is_err());
+/// assert!(space().parse("").is_err());
+/// ```
 #[inline(always)]
 pub fn space<I>() -> Space<I>
 where
@@ -60,6 +71,13 @@ impl_token_parser! { Spaces(), char, Expected<SkipMany<Space<I>>> }
 /// This includes space characters, tabs and newlines.
 ///
 /// [`std::char::is_whitespace`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_whitespace
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::spaces;
+/// assert_eq!(spaces().parse(""), Ok(((), "")));
+/// assert_eq!(spaces().parse("   "), Ok(((), "")));
+/// ```
 #[inline(always)]
 pub fn spaces<I>() -> Spaces<I>
 where
@@ -71,6 +89,13 @@ where
 impl_token_parser! { Newline(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 
 /// Parses a newline character.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::newline;
+/// assert_eq!(newline().parse("\n"), Ok(('\n', "")));
+/// assert!(newline().parse("\r").is_err());
+/// ```
 #[inline(always)]
 pub fn newline<I>() -> Newline<I>
 where
@@ -85,6 +110,14 @@ where
 impl_token_parser! { CrLf(), char, Expected<With<Satisfy<I, fn (char) -> bool>, Newline<I>>> }
 
 /// Parses carriage return and newline, returning the newline character.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::crlf;
+/// assert_eq!(crlf().parse("\r\n"), Ok(('\n', "")));
+/// assert!(crlf().parse("\r").is_err());
+/// assert!(crlf().parse("\n").is_err());
+/// ```
 #[inline(always)]
 pub fn crlf<I>() -> CrLf<I>
 where
@@ -101,6 +134,13 @@ where
 impl_token_parser! { Tab(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 
 /// Parses a tab character.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::tab;
+/// assert_eq!(tab().parse("\t"), Ok(('\t', "")));
+/// assert!(tab().parse(" ").is_err());
+/// ```
 #[inline(always)]
 pub fn tab<I>() -> Tab<I>
 where
@@ -117,6 +157,13 @@ impl_token_parser! { Upper(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 /// Parses an uppercase letter according to [`std::char::is_uppercase`].
 ///
 /// [`std::char::is_uppercase`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_uppercase
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::upper;
+/// assert_eq!(upper().parse("A"), Ok(('A', "")));
+/// assert!(upper().parse("a").is_err());
+/// ```
 #[inline(always)]
 pub fn upper<I>() -> Upper<I>
 where
@@ -133,6 +180,13 @@ impl_token_parser! { Lower(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 /// Parses an lowercase letter according to [`std::char::is_lowercase`].
 ///
 /// [`std::char::is_lowercase`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_lowercase
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::lower;
+/// assert_eq!(lower().parse("a"), Ok(('a', "")));
+/// assert!(lower().parse("A").is_err());
+/// ```
 #[inline(always)]
 pub fn lower<I>() -> Lower<I>
 where
@@ -149,6 +203,14 @@ impl_token_parser! { AlphaNum(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 /// Parses either an alphabet letter or digit according to [`std::char::is_alphanumeric`].
 ///
 /// [`std::char::is_alphanumeric`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::alpha_num;
+/// assert_eq!(alpha_num().parse("A"), Ok(('A', "")));
+/// assert_eq!(alpha_num().parse("1"), Ok(('1', "")));
+/// assert!(alpha_num().parse("!").is_err());
+/// ```
 #[inline(always)]
 pub fn alpha_num<I>() -> AlphaNum<I>
 where
@@ -166,6 +228,14 @@ impl_token_parser! { Letter(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 /// Parses an alphabet letter according to [`std::char::is_alphabetic`].
 ///
 /// [`std::char::is_alphabetic`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_alphabetic
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::letter;
+/// assert_eq!(letter().parse("a"), Ok(('a', "")));
+/// assert_eq!(letter().parse("A"), Ok(('A', "")));
+/// assert!(letter().parse("9").is_err());
+/// ```
 #[inline(always)]
 pub fn letter<I>() -> Letter<I>
 where
@@ -180,6 +250,13 @@ where
 impl_token_parser! { OctDigit(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 
 /// Parses an octal digit.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::oct_digit;
+/// assert_eq!(oct_digit().parse("7"), Ok(('7', "")));
+/// assert!(oct_digit().parse("8").is_err());
+/// ```
 #[inline(always)]
 pub fn oct_digit<I>() -> OctDigit<I>
 where
@@ -194,6 +271,13 @@ where
 impl_token_parser! { HexDigit(), char, Expected<Satisfy<I, fn (char) -> bool>> }
 
 /// Parses a hexdecimal digit with uppercase and lowercase.
+///
+/// ```
+/// use combine::Parser;
+/// use combine::char::hex_digit;
+/// assert_eq!(hex_digit().parse("F"), Ok(('F', "")));
+/// assert!(hex_digit().parse("H").is_err());
+/// ```
 #[inline(always)]
 pub fn hex_digit<I>() -> HexDigit<I>
 where
diff --git a/src/lib.rs b/src/lib.rs
index 780203b4..495b5933 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -404,18 +404,14 @@ mod tests {
     #[test]
     fn sep_by_error_consume() {
         let mut p = sep_by::<Vec<_>, _, _>(string("abc"), char(','));
-        let err = p.parse(State::new("ab,abc"))
-            .map(|x| format!("{:?}", x))
-            .unwrap_err();
+        let err = p.parse(State::new("ab,abc")).unwrap_err();
         assert_eq!(err.position, SourcePosition { line: 1, column: 1 });
     }
 
     #[test]
     fn optional_error_consume() {
         let mut p = optional(string("abc"));
-        let err = p.parse(State::new("ab"))
-            .map(|x| format!("{:?}", x))
-            .unwrap_err();
+        let err = p.parse(State::new("ab")).unwrap_err();
         assert_eq!(err.position, SourcePosition { line: 1, column: 1 });
     }
     #[test]


Test patch: