Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-core/src/search.rs')
-rw-r--r--helix-core/src/search.rs26
1 files changed, 2 insertions, 24 deletions
diff --git a/helix-core/src/search.rs b/helix-core/src/search.rs
index 81cb4129..243ac227 100644
--- a/helix-core/src/search.rs
+++ b/helix-core/src/search.rs
@@ -1,28 +1,6 @@
use crate::RopeSlice;
-// TODO: switch to std::str::Pattern when it is stable.
-pub trait CharMatcher {
- fn char_match(&self, ch: char) -> bool;
-}
-
-impl CharMatcher for char {
- fn char_match(&self, ch: char) -> bool {
- *self == ch
- }
-}
-
-impl<F: Fn(&char) -> bool> CharMatcher for F {
- fn char_match(&self, ch: char) -> bool {
- (*self)(&ch)
- }
-}
-
-pub fn find_nth_next<M: CharMatcher>(
- text: RopeSlice,
- char_matcher: M,
- mut pos: usize,
- n: usize,
-) -> Option<usize> {
+pub fn find_nth_next(text: RopeSlice, ch: char, mut pos: usize, n: usize) -> Option<usize> {
if pos >= text.len_chars() || n == 0 {
return None;
}
@@ -35,7 +13,7 @@ pub fn find_nth_next<M: CharMatcher>(
pos += 1;
- if char_matcher.char_match(c) {
+ if c == ch {
break;
}
}