Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/combinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ where
type Item = Output;

fn next(&mut self) -> Option<Self::Item> {
if let State::Running = self.state.take().unwrap() {
if let Some(State::Running) = self.state {
let input = self.input.clone();

match (self.iterator).parse(input) {
Expand Down
23 changes: 23 additions & 0 deletions src/combinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,26 @@ fn fail_test() {
Err(Err::Error((b, ErrorKind::Fail)))
);
}

#[test]
fn parser_iterator_test() {
use crate::character::complete::alpha1;
use crate::sequence::terminated;
use crate::IResult;

let input: &str = "next:test:";

let mut nom_it = iterator(input, terminated(alpha1, tag(":")));

assert_eq!(Some("next"), nom_it.next());
assert_eq!(Some("test"), nom_it.next());

// and then None once it's over.
assert_eq!(None, nom_it.next());

// None for more calls
assert_eq!(None, nom_it.next());

let parser_result: IResult<_, _> = nom_it.finish();
assert_eq!(Ok(("", ())), parser_result);
}