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
It would be useful to be able to use nom with the Bytes type from the bytes and the types from other similar crates such as arc-slice and byteview. While using these types does not speed up parsing with nom itself, they do help significantly in the post-processing stage in achieving zero-copy by avoiding unnecessary allocations as .clone() is much cheaper due to it incrementing an atomic reference counter and taking a subslice, rather than allocating more memory and copying over the subslice.
Unfortunately, it is not entirely clear to me how to implement the Input trait (and perhaps other traits) for such a type due to the lifetime used in type Iter = Copied<Iter<'a, u8>>; whereas Bytes lacks a lifetime (since it is akin to Arc<[u8]> rather than &'a u8). Implementation is rather trivial other than for the lifetime issue, but I am not sure how to proceed with fixing the lifetime issue itself:
It would be useful to be able to use nom with the
Bytes
type from the bytes and the types from other similar crates such as arc-slice and byteview. While using these types does not speed up parsing with nom itself, they do help significantly in the post-processing stage in achieving zero-copy by avoiding unnecessary allocations as.clone()
is much cheaper due to it incrementing an atomic reference counter and taking a subslice, rather than allocating more memory and copying over the subslice.Unfortunately, it is not entirely clear to me how to implement the
Input
trait (and perhaps other traits) for such a type due to the lifetime used intype Iter = Copied<Iter<'a, u8>>;
whereasBytes
lacks a lifetime (since it is akin toArc<[u8]>
rather than&'a u8
). Implementation is rather trivial other than for the lifetime issue, but I am not sure how to proceed with fixing the lifetime issue itself:The text was updated successfully, but these errors were encountered: