aboutsummaryrefslogtreecommitdiff
path: root/src/expand.rs
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-07 05:00:00 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-07 05:00:00 +0000
commit717ad20fd789c2265cc87cef2b50a0f73c0d9fd4 (patch)
treed050b095d3d08bc7800c98bf5fe9e2ec15a35921 /src/expand.rs
parent91918a6c3087eebc7f8d3c673560984d8defe3dc (diff)
parent14bea0e36ba5a038a98be2269a0450fe90c9d229 (diff)
downloadregex-aml_mpr_341015090.tar.gz
Change-Id: I30671fe075664b0608b79d247740d85495768ae4
Diffstat (limited to 'src/expand.rs')
-rw-r--r--src/expand.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/expand.rs b/src/expand.rs
index fd9c2d0..67b5149 100644
--- a/src/expand.rs
+++ b/src/expand.rs
@@ -127,7 +127,7 @@ impl From<usize> for Ref<'static> {
/// If no such valid reference could be found, None is returned.
fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef<'_>> {
let mut i = 0;
- let rep: &[u8] = replacement.as_ref();
+ let rep: &[u8] = replacement;
if rep.len() <= 1 || rep[0] != b'$' {
return None;
}
@@ -136,7 +136,7 @@ fn find_cap_ref(replacement: &[u8]) -> Option<CaptureRef<'_>> {
return find_cap_ref_braced(rep, i + 1);
}
let mut cap_end = i;
- while rep.get(cap_end).map_or(false, is_valid_cap_letter) {
+ while rep.get(cap_end).copied().map_or(false, is_valid_cap_letter) {
cap_end += 1;
}
if cap_end == i {
@@ -183,8 +183,8 @@ fn find_cap_ref_braced(rep: &[u8], mut i: usize) -> Option<CaptureRef<'_>> {
}
/// Returns true if and only if the given byte is allowed in a capture name.
-fn is_valid_cap_letter(b: &u8) -> bool {
- match *b {
+fn is_valid_cap_letter(b: u8) -> bool {
+ match b {
b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' | b'_' => true,
_ => false,
}