diff --git a/src/multi/mod.rs b/src/multi/mod.rs index a1436d6d..d78611f9 100644 --- a/src/multi/mod.rs +++ b/src/multi/mod.rs @@ -335,7 +335,7 @@ where /// [`cut`][crate::combinator::cut]. /// /// # Arguments -/// * `sep` Parses the separator between list elements. Must be consuming. +/// * `sep` Parses the separator between list elements. /// * `f` Parses the elements of the list. /// /// ```rust @@ -457,7 +457,7 @@ where /// [`cut`][crate::combinator::cut]. /// /// # Arguments -/// * `sep` Parses the separator between list elements. Must be consuming. +/// * `sep` Parses the separator between list elements. /// * `f` Parses the elements of the list. /// ```rust /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult, Parser}; diff --git a/src/multi/tests.rs b/src/multi/tests.rs index 080240cd..1003552f 100644 --- a/src/multi/tests.rs +++ b/src/multi/tests.rs @@ -82,6 +82,9 @@ fn separated_list1_test() { fn multi_longsep(i: &[u8]) -> IResult<&[u8], Vec<&[u8]>> { separated_list1(tag(".."), tag("abcd")).parse(i) } + fn empty_both(i: &[u8]) -> IResult<&[u8], Vec<&[u8]>> { + separated_list0(tag(""), tag("")).parse(i) + } let a = &b"abcdef"[..]; let b = &b"abcd,abcdef"[..]; @@ -100,6 +103,10 @@ fn separated_list1_test() { multi(c), Err(Err::Error(error_position!(c, ErrorKind::Tag))) ); + assert_eq!( + empty_both(f), + Err(Err::Error(error_position!(f, ErrorKind::SeparatedList))) + ); let res3 = vec![&b"abcd"[..], &b"abcd"[..]]; assert_eq!(multi(d), Ok((&b",ef"[..], res3)));