Repository: Geal/nom
Pull request #980 (2019-07-01 12:01:43)

Fix incorrect types in documentation of named! and named_args!.
I didn’t check all occurrences of the `&[u8]` pattern but at least those are fixed.

phaazon: Current situation [here](https://docs.rs/nom/5.0.0/nom/macro.named.html).

![Screenshot 2019-07-01 at 14 02 23](https://user-images.githubusercontent.com/506592/60435052-dd6b9f00-9c08-11e9-813e-e6db10f25293.png)

phaazon: Fixed.

![Screenshot 2019-07-01 at 14 03 24](https://user-images.githubusercontent.com/506592/60435123-02f8a880-9c09-11e9-8708-7f8b104c4d38.png)

coveralls: 
[![Coverage Status](https://coveralls.io/builds/24300160/badge)](https://coveralls.io/builds/24300160)

Coverage remained the same at 87.126% when pulling **31f8754787850347212b9c2bd5774cc8cee50b3c on phaazon:fix/doc-types** into **0efdfac0cc183a673f36d24f8c634bec0fb9d687 on Geal:master**.


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 2d98d26..f7b3788 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -108,6 +108,7 @@ name = "json"
 
 [[test]]
 name = "mp4"
+required-features = ["alloc"]
 
 [[test]]
 name = "multiline"
diff --git a/src/combinator/macros.rs b/src/combinator/macros.rs
index aa164e2..ca80e2a 100644
--- a/src/combinator/macros.rs
+++ b/src/combinator/macros.rs
@@ -79,12 +79,12 @@
 /// # use nom::{named, tag};
 /// named!(my_function<&[u8], &[u8]>, tag!("abcd"));
 /// ```
-/// This one will have &[u8] as input type, &[u8] as output type:
+/// This one will have `&[u8]` as input type, `&[u8]` as output type:
 /// ```
 /// # use nom::{named, tag};
 /// named!(my_function, tag!("abcd"));
 /// ```
-/// Will use &[u8] as output type:
+/// Will use `&[u8]` as output type:
 /// ```
 /// # use nom::{named, tag};
 /// named!(my_function<&[u8]>, tag!("abcd"));
@@ -134,7 +134,7 @@ macro_rules! named (
 /// Makes a function from a parser combination with arguments.
 ///
 /// ```ignore
-/// //takes `&[u8]` as input
+/// //takes [`&[u8]`] as input
 /// named_args!(tagged(open_tag: &[u8], close_tag: &[u8])<&str>,
 ///   delimited!(tag!(open_tag), map_res!(take!(4), str::from_utf8), tag!(close_tag))
 /// );
diff --git a/src/lib.rs b/src/lib.rs
index 144ed20..d59df95 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -422,7 +422,7 @@ extern crate test;
 #[cfg(test)]
 extern crate doc_comment;
 
-#[cfg(test)]
+#[cfg(doctest)]
 doc_comment::doctest!("../README.md");
 
 /// Lib module to re-export everything needed from `std` or `core`/`alloc`. This is how `serde` does
diff --git a/src/multi/mod.rs b/src/multi/mod.rs
index 269fc44..93b3e4c 100644
--- a/src/multi/mod.rs
+++ b/src/multi/mod.rs
@@ -409,6 +409,10 @@ where
     let mut input = i.clone();
     let mut count: usize = 0;
 
+    if n == 0 {
+        return Ok((i, vec!()))
+    }
+
     loop {
       let _i = input.clone();
       match f(_i) {


Test patch:
diff --git a/tests/issues.rs b/tests/issues.rs
index a7bf516..094b47c 100644
--- a/tests/issues.rs
+++ b/tests/issues.rs
@@ -290,3 +290,11 @@ fn issue_942() {
   }
   assert_eq!(parser::<()>("aaa"), Ok(("", 3)));
 }
+
+#[test]
+fn issue_many_m_n_with_zeros() {
+    use nom::multi::many_m_n;
+    use nom::character::complete::char;
+    let parser = many_m_n::<_, _, (), _>(0, 0, char('a'));
+    assert_eq!(parser("aaa"), Ok(("aaa", vec!())));
+}