Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ContextAwareParse to return CommandMatches #328

Merged
merged 3 commits into from
Sep 21, 2023

Conversation

MikkelPaulson
Copy link
Collaborator

Previously, the return type of ContextAwareParse::parse_input() was (Option<Self>, Vec<Self>) with no real explanation of why. This has now been updated to a properly-documented struct called CommandMatches<T>. It also provides convenience functions for converting and combining multiple sets of matches, consolidating some (admittedly simple) logic that was previously scattered all over the place.

Normally I try to keep commits small and numerous in each branch, but this is one of those rip-the-bandaid changes.

Resolves #325.

Previously, the return type of `ContextAwareParse::parse_input()` was
`(Option<Self>, Vec<Self>)` with no real explanation of why. This has
now been updated to a properly-documented struct called
`CommandMatches<T>`. It also provides convenience functions for
converting and combining multiple sets of matches, consolidating some
(admittedly simple) logic that was previously scattered all over the
place.
@MikkelPaulson MikkelPaulson force-pushed the return-struct-from-context-aware-parse branch from afd8852 to c0b03ec Compare September 21, 2023 14:45
@MikkelPaulson
Copy link
Collaborator Author

@alfonsomartinezs FYI - this should make the parser handling that we paired on a bit more intuitive, at the expense of possibly breaking the draft branch.

I belatedly realized that `some_vec.drain(..)` is equivalent to
`some_vec.into_iter()`, except the latter is more flexible and consumes
the input in-place rather than requiring it to be mutable. Every
instance of `drain(..)` in the code base was better served by
`into_iter()`.
@MikkelPaulson MikkelPaulson force-pushed the return-struct-from-context-aware-parse branch from f7c5532 to ad04c74 Compare September 21, 2023 15:10
@MikkelPaulson MikkelPaulson merged commit 95f706e into main Sep 21, 2023
3 of 4 checks passed
@MikkelPaulson MikkelPaulson deleted the return-struct-from-context-aware-parse branch September 21, 2023 15:17
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.

Improve ergonomics of ContextAwareParse return value
1 participant