pub struct Atom {
pub negative: bool,
pub kind: AtomKind,
/* private fields */
}Expand description
A single pattern component that is matched with a single Matcher function.
Fields§
§negative: boolWhether this pattern atom is a negative match. A negative pattern atom will prevent haystacks matching it from being matchend. It does not contribute to scoring/indices
kind: AtomKindThe kind of match that this pattern performs
Implementations§
Source§impl Atom
impl Atom
Sourcepub fn new(
needle: &str,
case: CaseMatching,
normalize: Normalization,
kind: AtomKind,
escape_whitespace: bool,
) -> Atom
pub fn new( needle: &str, case: CaseMatching, normalize: Normalization, kind: AtomKind, escape_whitespace: bool, ) -> Atom
Creates a single Atom from a string by performing unicode
normalization and case folding (if necessary). Optionally \ can
be escaped to .
Sourcepub fn parse(raw: &str, case: CaseMatching, normalize: Normalization) -> Atom
pub fn parse(raw: &str, case: CaseMatching, normalize: Normalization) -> Atom
Parse a pattern atom from a string. Some special trailing and leading
characters can be used to control the atom kind. See AtomKind for
details.
Sourcepub fn score(
&self,
haystack: Utf32Str<'_>,
matcher: &mut Matcher,
) -> Option<u16>
pub fn score( &self, haystack: Utf32Str<'_>, matcher: &mut Matcher, ) -> Option<u16>
Matches this pattern against haystack (using the allocation and configuration
from matcher) and calculates a ranking score. See the Matcher.
Documentation for more details.
Note: The ignore_case setting is overwritten to match the casing of
each pattern atom.
Sourcepub fn indices(
&self,
haystack: Utf32Str<'_>,
matcher: &mut Matcher,
indices: &mut Vec<u32>,
) -> Option<u16>
pub fn indices( &self, haystack: Utf32Str<'_>, matcher: &mut Matcher, indices: &mut Vec<u32>, ) -> Option<u16>
Matches this pattern against haystack (using the allocation and
configuration from matcher), calculates a ranking score and the match
indices. See the Matcher. Documentation for more
details.
Note: The ignore_case setting is overwritten to match the casing of
each pattern atom.
Note: The indices vector is not cleared by this function.
Sourcepub fn needle_text(&self) -> Utf32Str<'_>
pub fn needle_text(&self) -> Utf32Str<'_>
Returns the needle text that is passed to the matcher. All indices
produced by the indices functions produce char indices used to index
this text
Sourcepub fn match_list<T>(
&self,
items: impl IntoIterator<Item = T>,
matcher: &mut Matcher,
) -> Vec<(T, u16)>
pub fn match_list<T>( &self, items: impl IntoIterator<Item = T>, matcher: &mut Matcher, ) -> Vec<(T, u16)>
Convenience function to easily match (and sort) a (relatively small) list of inputs.
Note This function is not recommended for building a full fuzzy
matching application that can match large numbers of matches (like all
files in a directory) as all matching is done on the current thread,
effectively blocking the UI. For such applications the high level
nucleo crate can be used instead.
Trait Implementations§
impl Eq for Atom
impl StructuralPartialEq for Atom
Auto Trait Implementations§
impl Freeze for Atom
impl RefUnwindSafe for Atom
impl Send for Atom
impl Sync for Atom
impl Unpin for Atom
impl UnwindSafe for Atom
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more