Skip to content

Optimize multi-char string patterns #138537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/core/src/slice/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,4 @@ macro_rules! impl_slice_contains {
};
}

impl_slice_contains!(u16, u32, u64, i16, i32, i64, f32, f64, usize, isize);
impl_slice_contains!(u16, u32, u64, i16, i32, i64, f32, f64, usize, isize, char);
6 changes: 3 additions & 3 deletions library/core/src/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,21 +644,21 @@ where
impl<const N: usize> MultiCharEq for [char; N] {
#[inline]
fn matches(&mut self, c: char) -> bool {
self.iter().any(|&m| m == c)
self.contains(&c)
}
}

impl<const N: usize> MultiCharEq for &[char; N] {
#[inline]
fn matches(&mut self, c: char) -> bool {
self.iter().any(|&m| m == c)
self.contains(&c)
}
}

impl MultiCharEq for &[char] {
#[inline]
fn matches(&mut self, c: char) -> bool {
self.iter().any(|&m| m == c)
self.contains(&c)
}
}

Expand Down
Loading