Skip to content

Added a combinator similar to separated_list0, but that allows for a trailing separator. (doc)tests are mostly complete.#1874

Open
SleighPenguin22 wants to merge 2 commits into
rust-bakery:mainfrom
SleighPenguin22:combinator_separated_list_trailing0
Open

Added a combinator similar to separated_list0, but that allows for a trailing separator. (doc)tests are mostly complete.#1874
SleighPenguin22 wants to merge 2 commits into
rust-bakery:mainfrom
SleighPenguin22:combinator_separated_list_trailing0

Conversation

@SleighPenguin22

@SleighPenguin22 SleighPenguin22 commented Jan 5, 2026

Copy link
Copy Markdown

The multi module provides a separated_list\[01\]() combinator, but the combinator does not consume a trailing separator, defining my own in my project using a macro is doable, but looks weird when compared to the provided function API.

I'm proposing a combinator whose interface is identical to separated_list[01](sep, parser), but it accepts an optional trailing separator and discards it.

but that allows for a trailing separator.
(doc)tests are mostly complete.
@SleighPenguin22
SleighPenguin22 requested a review from Geal as a code owner January 5, 2026 11:39
@SleighPenguin22

Copy link
Copy Markdown
Author

Now that I think of it, perhaps the SeparatedList[01] Structs could instead have a boolean field that specifies if a trailing separator should be consumed at runtime?
the constructor then constructs the corresponding struct with the field set to true or false depending on the called constructor (i.e. separated_list0(...) sets it false while separated_list_trailing0(...) sets it true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant