Skip to content

Commit 4ef6847

Browse files
committed
Use memchr for [i8]::contains as well
1 parent 1d818a4 commit 4ef6847

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libcore/slice/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2635,3 +2635,11 @@ impl SliceContains for u8 {
26352635
memchr::memchr(*self, x).is_some()
26362636
}
26372637
}
2638+
2639+
impl SliceContains for i8 {
2640+
fn slice_contains(&self, x: &[Self]) -> bool {
2641+
let byte = *self as u8;
2642+
let bytes: &[u8] = unsafe { from_raw_parts(x.as_ptr() as *const u8, x.len()) };
2643+
memchr::memchr(byte, bytes).is_some()
2644+
}
2645+
}

0 commit comments

Comments
 (0)