You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to experiment with porting toml_edit to nom, one thing I especially found missing was custom collection support. If I use many0, it only supports Vec. The naive approach in code is to do
which will collect directly into the String, saving on a lot of allocations
I'm also looking at optimizing a section of my parser where collect into a Vec and then turn it into a HashMap with errors by creating a custom type that wraps HashMap with my error type and stores off errors on Extend, allowing me to bypass the Vec allocation.
I could do all of this with fold_ variants but it will be a bit messier.
I wonder if this can replace the existing ExtendInto trait used for escapes. That instead is determined based on the input type and we'd be switching it to be based on the output type.
epage
added a commit
to epage/winnow
that referenced
this issue
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.
Fixeswinnow-rs#122
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.
Fixeswinnow-rs#122
epage
added a commit
to epage/winnow
that referenced
this issue
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.
Fixeswinnow-rs#122
Please complete the following tasks
winnow version
0.2.0
Describe your use case
I wanted to experiment with porting
toml_edit
to nom, one thing I especially found missing was custom collection support. If I usemany0
, it only supportsVec
. The naive approach in code is to doLeading me to allocate a
Vec<String>
and then merge them.combine
defaults toVec
but allows anyExtend
type, allowingwhich will collect directly into the
String
, saving on a lot of allocationsI'm also looking at optimizing a section of my parser where collect into a
Vec
and then turn it into aHashMap
with errors by creating a custom type that wrapsHashMap
with my error type and stores off errors onExtend
, allowing me to bypass theVec
allocation.I could do all of this with
fold_
variants but it will be a bit messier.Describe the solution you'd like
Minimum
Ideal
One option I've been considering is
(
Err
was added last minute to support #99)We could implement this for
()
usize
String
Vec
HashMap
BTreeMap
winnow::*::Extendable
which wraps anyDefault + Extend
Questions
Extendable
liveAlternatives, if applicable
rust-bakery/nom#1621 solved this by supporting any
Default + Extends
container, losing pre-allocationsAdditional Context
No response
The text was updated successfully, but these errors were encountered: