Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
While using mecha I found my self wanting to parse lists of an unknown length. The pre-exisitng
manyRange
does this however returns a string instead of the objects parsed. I couldn't find any pre-existing method in mecha to facilitate getting the objects parsed. This pull request implements one way of extracting the parsed elements.First it adds an
Iterator(T)
struct which functions like other iterators instd
, there is anext()
function which returns the nextT
if it exists and null if the iterator is exhausted. This is backed by a string + parser combination where next just calls the parser on the string to get the next element and parse failure is considered the end of the iterator.Then it adds a
manyRangeIterator
parser which first runsmanyRange
on the input to get the string representing the list of values parsed then wraps it up in an Iterator. The "Many Iterator" test shows the intended use pattern.Concerns
manyIterator
andmanyRangeIterator
maybe some one has a better idea bout the organization of these things.