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

feat(multi): Switch from Vec to impl Accumulate #127

Merged
merged 5 commits into from
Feb 3, 2023
Merged

Conversation

epage
Copy link
Collaborator

@epage epage commented Feb 3, 2023

I went with a custom trait so we could cover () and usize as well as
support custom capacities.

This comes at the cost of supporting any container possible. We could
possibly do that with a Extendable(T: Default + Extend) newtype.

As an alternative to () and usize is GATs. The main difference is
who drives the types.

This allowed us to deprecate many[01]_count.

Along the way, we also updated escaped_transform to this so we use this consistently. This exposed why #19 was broken. ExtendInto was implemented both for input and for outputs for the two parsers, which was meant to include char. The backward design of the trait made this less obvious what was happening which I feel is a win for the new trait design.

However, now that Accumulate has no input connection, there isn't quite a proper home for this...

I am conflicted about needing to annotate types when passing a many into something that ignores the output, like recognize. In some respects, I want to require the output type into parsers like recognize to be () but that that will require a lot of void() as that is the minority case. This is a benefit to the GAT approach.

Fixes #122

BREAKING CHANGE: The trait and behavior for escaped_transform changed due to replacing ExtendInto with Accumulate.

I went with a custom trait so we could cover `()` and `usize` as well as
support custom capacities.

This comes at the cost of supporting any container possible.  We could
possibly do that with a `Extendable(T: Default + Extend)` newtype.

As an alternative to `()` and `usize` is GATs.  The main difference is
who drives the types.

Fixes winnow-rs#122
@coveralls
Copy link

coveralls commented Feb 3, 2023

Pull Request Test Coverage Report for Build 4088401767

  • 46 of 80 (57.5%) changed or added relevant lines in 4 files are covered.
  • 30 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-1.3%) to 57.261%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/bytes/complete.rs 3 5 60.0%
src/bytes/streaming.rs 0 4 0.0%
src/multi/mod.rs 23 27 85.19%
src/input.rs 20 44 45.45%
Files with Coverage Reduction New Missed Lines %
src/character/complete.rs 2 81.45%
src/multi/mod.rs 28 79.37%
Totals Coverage Status
Change from base Build 4088205250: -1.3%
Covered Lines: 1668
Relevant Lines: 2913

💛 - Coveralls

@epage epage force-pushed the extend branch 3 times, most recently from d009a7b to 1414499 Compare February 3, 2023 22:29
@epage epage merged commit 77623fd into winnow-rs:main Feb 3, 2023
@epage epage deleted the extend branch February 3, 2023 22:44
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.

Support custom containers for many functions
2 participants