Search &[u8]
haystacks in regex_lite
#1274
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To quote the
regex_lite
docs:This PR adds such an API in form of
regex_lite::bytes::Regex
, mirroringregex::bytes::Regex
.Thanks, @BurntSushi, for leaving some breadcrumbs in the source code that made this easier, in particular your hint in
interpolate::bytes
. This is much appreciated, as well as all your effort that went not only in the careful and beautiful API design, but also your very detailed and user-friendly documentation. Thanks a lot for your awesome work.I made this PR because I need this functionality as part of jaq, where I want to transition from
String
to (a variation of)Vec<u8>
, inspired by your "UTF-8 by convention" idea.I did not
cargo fmt
this PR in order to make reviewing as easy as possible.(Note to self: If I ever have to convert a lot of
b"foo"
to&b"foo"[..]
again, this is how to do it in vim for all matches on the current line::s/b"\([^"]*\)"/\&b"\1"[..]/g
.)