Skip to content

Commit

Permalink
Remove the blanket implementation for reference of Automaton
Browse files Browse the repository at this point in the history
  • Loading branch information
momvart committed Nov 16, 2024
1 parent 948d2e1 commit 23b3cc0
Showing 1 changed file with 4 additions and 88 deletions.
92 changes: 4 additions & 88 deletions src/automaton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<A: Automaton>(
/// aut: A,
/// aut: &A,
/// haystack: &[u8],
/// ) -> Result<Option<Match>, MatchError> {
/// let mut sid = aut.start_state(Anchored::No)?;
Expand Down Expand Up @@ -355,7 +355,7 @@ pub unsafe trait Automaton: private::Sealed {
&self,
input: &Input<'_>,
) -> Result<Option<Match>, MatchError> {
try_find_fwd(&self, input)
try_find_fwd(self, input)
}

/// Executes a overlapping search with this automaton using the given
Expand All @@ -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
Expand Down Expand Up @@ -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<StateID, MatchError> {
(**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
Expand Down Expand Up @@ -1557,7 +1473,7 @@ fn get_match<A: Automaton + ?Sized>(
/// overlapping is that of match and start states.)
pub(crate) fn fmt_state_indicator<A: Automaton>(
f: &mut core::fmt::Formatter<'_>,
aut: A,
aut: &A,
id: StateID,
) -> core::fmt::Result {
if aut.is_dead(id) {
Expand Down

0 comments on commit 23b3cc0

Please sign in to comment.