diff --git a/src/automaton.rs b/src/automaton.rs index c41dc6e..040d1d9 100644 --- a/src/automaton.rs +++ b/src/automaton.rs @@ -141,7 +141,7 @@ impl<'a, T: private::Sealed + ?Sized> private::Sealed for &'a T {} /// // seen according to the automaton's match semantics. This returns an error /// // if the given automaton does not support unanchored searches. /// fn find( -/// aut: A, +/// aut: &A, /// haystack: &[u8], /// ) -> Result, MatchError> { /// let mut sid = aut.start_state(Anchored::No)?; @@ -355,7 +355,7 @@ pub unsafe trait Automaton: private::Sealed { &self, input: &Input<'_>, ) -> Result, MatchError> { - try_find_fwd(&self, input) + try_find_fwd(self, input) } /// Executes a overlapping search with this automaton using the given @@ -369,7 +369,7 @@ pub unsafe trait Automaton: private::Sealed { input: &Input<'_>, state: &mut OverlappingState, ) -> Result<(), MatchError> { - try_find_overlapping_fwd(&self, input, state) + try_find_overlapping_fwd(self, input, state) } /// Returns an iterator of non-overlapping matches with this automaton @@ -636,90 +636,6 @@ pub unsafe trait Automaton: private::Sealed { } } -// SAFETY: This just defers to the underlying 'AcAutomaton' and thus inherits -// its safety properties. -unsafe impl<'a, A: Automaton + ?Sized> Automaton for &'a A { - #[inline(always)] - fn start_state(&self, anchored: Anchored) -> Result { - (**self).start_state(anchored) - } - - #[inline(always)] - fn next_state( - &self, - anchored: Anchored, - sid: StateID, - byte: u8, - ) -> StateID { - (**self).next_state(anchored, sid, byte) - } - - #[inline(always)] - fn is_special(&self, sid: StateID) -> bool { - (**self).is_special(sid) - } - - #[inline(always)] - fn is_dead(&self, sid: StateID) -> bool { - (**self).is_dead(sid) - } - - #[inline(always)] - fn is_match(&self, sid: StateID) -> bool { - (**self).is_match(sid) - } - - #[inline(always)] - fn is_start(&self, sid: StateID) -> bool { - (**self).is_start(sid) - } - - #[inline(always)] - fn match_kind(&self) -> MatchKind { - (**self).match_kind() - } - - #[inline(always)] - fn match_len(&self, sid: StateID) -> usize { - (**self).match_len(sid) - } - - #[inline(always)] - fn match_pattern(&self, sid: StateID, index: usize) -> PatternID { - (**self).match_pattern(sid, index) - } - - #[inline(always)] - fn patterns_len(&self) -> usize { - (**self).patterns_len() - } - - #[inline(always)] - fn pattern_len(&self, pid: PatternID) -> usize { - (**self).pattern_len(pid) - } - - #[inline(always)] - fn min_pattern_len(&self) -> usize { - (**self).min_pattern_len() - } - - #[inline(always)] - fn max_pattern_len(&self) -> usize { - (**self).max_pattern_len() - } - - #[inline(always)] - fn memory_usage(&self) -> usize { - (**self).memory_usage() - } - - #[inline(always)] - fn prefilter(&self) -> Option<&Prefilter> { - (**self).prefilter() - } -} - /// Represents the current state of an overlapping search. /// /// This is used for overlapping searches since they need to know something @@ -1557,7 +1473,7 @@ fn get_match( /// overlapping is that of match and start states.) pub(crate) fn fmt_state_indicator( f: &mut core::fmt::Formatter<'_>, - aut: A, + aut: &A, id: StateID, ) -> core::fmt::Result { if aut.is_dead(id) {