1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-06-30 22:23:44 +02:00

matcher: polish the grep-matcher crate

Not much here. Just updating to reflect my current style and bringing
the crate to the 2021 edition.
This commit is contained in:
Andrew Gallant
2023-09-25 16:48:25 -04:00
parent abfa65c2c1
commit 96f01b92a0
5 changed files with 41 additions and 49 deletions

View File

@ -1,5 +1,3 @@
use std::str;
use memchr::memchr;
/// Interpolate capture references in `replacement` and write the interpolation
@ -114,7 +112,7 @@ fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef<'_>> {
// therefore be valid UTF-8. If we really cared, we could avoid this UTF-8
// check with an unchecked conversion or by parsing the number straight
// from &[u8].
let cap = str::from_utf8(&replacement[i..cap_end])
let cap = std::str::from_utf8(&replacement[i..cap_end])
.expect("valid UTF-8 capture name");
if brace {
if !replacement.get(cap_end).map_or(false, |&b| b == b'}') {