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.
Hi,
I've wanted to be able to store repeated values into a structure of my choosing, instead of a
Vec
.This change does that, without needing a temporary intermediate
Vec
. I believe it will also improve performance as expressions like$(expression ** delim)
will currently create a temporaryVec
.Two examples from the tests of how this may improve some usage:
Currently this works by requiring the collection the values are stored into to implement
Default
andExtend
. It may sometimes be necessary to be explicit about the type like theItemCounter
example above. It also may not be able to infer the type of theExtend<T>
'sT
if it implements it for multiple types, in which case the new-type pattern might be necessary. I don't imagine that will be common though.Another pattern that might be useful is to be able to instantiate the collection type with some context. I'm not sure of a good way to do this at the moment. I looked into returning an iterator, but you still need to be able to evaluate whether parsing fails before the iterator is evaluated.