mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 13:05:18 +03:00
Use memchr for [i8]::contains as well
This commit is contained in:
@@ -2635,3 +2635,11 @@ fn slice_contains(&self, x: &[Self]) -> bool {
|
||||
memchr::memchr(*self, x).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
impl SliceContains for i8 {
|
||||
fn slice_contains(&self, x: &[Self]) -> bool {
|
||||
let byte = *self as u8;
|
||||
let bytes: &[u8] = unsafe { from_raw_parts(x.as_ptr() as *const u8, x.len()) };
|
||||
memchr::memchr(byte, bytes).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user