portmatching/matcher/many_patterns/
mod.rs

1//! Pattern matchers for many patterns simultaneously.
2//!
3//! The [`NaiveManyMatcher`] is a simple matcher that uses [`super::SinglePatternMatcher`]s
4//! to match each pattern separately.
5//!
6//! The [`LineGraphTrie`] is a more sophisticated matcher that uses a graph trie
7//! data structure to match all patterns at once.
8mod automaton;
9mod naive;
10
11use derive_more::{From, Into};
12use std::fmt;
13
14#[cfg(feature = "serde")]
15use serde::{Deserialize, Serialize};
16
17#[doc(inline)]
18pub use automaton::{ManyMatcher, UnweightedManyMatcher};
19#[doc(inline)]
20pub use naive::NaiveManyMatcher;
21
22/// ID for a pattern in a [`ManyPatternMatcher`].
23#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, From, Into, Hash)]
24#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
25pub struct PatternID(pub usize);
26
27impl fmt::Debug for PatternID {
28    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29        write!(f, "{:?}", self.0)
30    }
31}
32
33impl fmt::Display for PatternID {
34    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35        write!(f, "ID({})", self.0)
36    }
37}