diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2017-12-18 10:22:53 -0800 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2017-12-31 20:35:39 +0530 |
| commit | 4ef6847d4df609054caca328b69b4ee5335426ae (patch) | |
| tree | 5979116e18e5a6ccbf191520cef35aa020a498ec /src/libcore/slice | |
| parent | 1d818a4d8c3fa5b15ad2e2ab30531316565d556c (diff) | |
| download | rust-4ef6847d4df609054caca328b69b4ee5335426ae.tar.gz rust-4ef6847d4df609054caca328b69b4ee5335426ae.zip | |
Use memchr for [i8]::contains as well
Diffstat (limited to 'src/libcore/slice')
| -rw-r--r-- | src/libcore/slice/mod.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 346ee273311..7b08ec13102 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2635,3 +2635,11 @@ impl SliceContains for u8 { 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() + } +} |
