Atom

Struct Atom 

Source
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: bool

Whether 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: AtomKind

The kind of match that this pattern performs

Implementations§

Source§

impl Atom

Source

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 .

Source

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.

Source

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.

Source

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.

Source

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

Source

pub fn match_list<T>( &self, items: impl IntoIterator<Item = T>, matcher: &mut Matcher, ) -> Vec<(T, u16)>
where T: AsRef<str>,

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§

Source§

impl Clone for Atom

Source§

fn clone(&self) -> Atom

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Atom

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Atom

Source§

fn eq(&self, other: &Atom) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Atom

Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.