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'd like to parse data with generic input (so my input has bounds I: Input<Item=u8>), and store it in a Cow object. I tried many implementations but could not get it to work for all cases.
1/
I tried adding a bound for Input on the struct, however this makes using the Cow impossible:
This will not work, since Cow<'a, I> will be inferred as Cow<'a, &'a [u8]> (notice the extra &).
If I change this to use [u8] as I, this makes Cow work, but nom complains that [u8] does not satisfy Input.
2/
So, I tried changing I to make it easier to use Cow, and change the bound for Input:
With the code above, I can parse things using for ex &[u8] to build OctetString<[u8]>. However, I can't build custom input containing a span (similar to nom-locate) because this requires &CustomInput: Input<Item=u8>.
I tried implementing Input for &CustomInput but can't, because take and take_fromreturn aSelf`, and I can't return a reference on a stack object.
Q/
Is there a way to have a copy-on-write type as Input? Does someone have a better solution for this?
The text was updated successfully, but these errors were encountered:
Hi,
I'd like to parse data with generic input (so my input has bounds
I: Input<Item=u8>
), and store it in aCow
object. I tried many implementations but could not get it to work for all cases.1/
I tried adding a bound for
Input
on the struct, however this makes using theCow
impossible:This will not work, since
Cow<'a, I>
will be inferred asCow<'a, &'a [u8]>
(notice the extra&
).If I change this to use
[u8]
asI
, this makesCow
work, but nom complains that[u8]
does not satisfyInput
.2/
So, I tried changing
I
to make it easier to useCow
, and change the bound forInput
:Examples implementation which works for slices:
With the code above, I can parse things using for ex
&[u8]
to buildOctetString<[u8]>
. However, I can't build custom input containing a span (similar tonom-locate
) because this requires&CustomInput: Input<Item=u8>
.I tried implementing
Input
for&CustomInput
but can't, becausetake and
take_fromreturn a
Self`, and I can't return a reference on a stack object.Q/
Is there a way to have a copy-on-write type as
Input
? Does someone have a better solution for this?The text was updated successfully, but these errors were encountered: