From 61e2c232daf7cbf172d2aa4a00e50a5ae0d53080 Mon Sep 17 00:00:00 2001 From: Scott Godwin Date: Sun, 19 Jan 2020 20:29:46 -0800 Subject: [PATCH 1/2] Expose TwoWaySearcher's next and next_back functions --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d2ff97e..0eb7428 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -536,7 +536,7 @@ impl TwoWaySearcher { // How far we can jump when we encounter a mismatch is all based on the fact // that (u, v) is a critical factorization for the needle. #[inline(always)] - fn next(&mut self, haystack: &[u8], needle: &[u8], long_period: bool) + pub fn next(&mut self, haystack: &[u8], needle: &[u8], long_period: bool) -> S::Output where S: TwoWayStrategy { @@ -619,7 +619,7 @@ impl TwoWaySearcher { // To search in reverse through the haystack, we search forward through // a reversed haystack with a reversed needle, matching first u' and then v'. #[inline] - fn next_back(&mut self, haystack: &[u8], needle: &[u8], long_period: bool) + pub fn next_back(&mut self, haystack: &[u8], needle: &[u8], long_period: bool) -> S::Output where S: TwoWayStrategy { From 634d32be894b66ba445fa497c05c298ea6ba3a6d Mon Sep 17 00:00:00 2001 From: Scott Godwin Date: Sun, 19 Jan 2020 20:40:27 -0800 Subject: [PATCH 2/2] Make TwoWayStrategy public --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0eb7428..ff359a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -793,7 +793,7 @@ impl TwoWaySearcher { // TwoWayStrategy allows the algorithm to either skip non-matches as quickly // as possible, or to work in a mode where it emits Rejects relatively quickly. -trait TwoWayStrategy { +pub trait TwoWayStrategy { type Output; fn use_early_reject() -> bool; fn rejecting(usize, usize) -> Self::Output;