Matcher

Struct Matcher 

Source
pub struct Matcher { /* private fields */ }
Expand description

围绕 daachorse::DoubleArrayAhoCorasick 的简单适配器。 存储原始模式(按顺序),并提供一个辅助方法 用于获取每个模式在输入中首次出现的位置。

Implementations§

Source§

impl Matcher

Source

pub fn from_patterns<S: AsRef<str>>(patterns: &[S]) -> Self

从一组模式构建一个 Matcher(模式顺序重要)。 空模式会被忽略;至少需要一个非空模式。

Source

pub fn find_first_positions(&self, haystack: &[u8]) -> Vec<Option<usize>>

返回一个 Vec<Option>,表示每个模式的首次匹配起始位置 (顺序与构建 Matcher 时提供的模式相同)。

Source

pub fn patterns_len(&self) -> usize

Expose number of patterns

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.