pub struct Pattern {
pub sortable: bool,
pub cacheable: bool,
pub scheme: Scheme,
/* private fields */
}Expand description
A parsed query, ready to score any number of lines.
Fields§
§sortable: boolfzf’s sortable (pattern.go:100): a query of nothing but inverse terms
scores every survivor 0, so fzf leaves them in input order instead of
letting the tiebreak reshuffle them.
cacheable: boolfzf’s cacheable (pattern.go:115): every term set is a single plain,
non-inverse term, so extending the query can only ever NARROW the result
set. This is what makes the picker’s incremental re-filter sound — an
inverse term or an | can WIDEN it, and then the old hit set is not a
superset of the new one.
scheme: Scheme--scheme: which characters count as boundaries and what a match just
after one is worth. Carried on the pattern so the scorer never depends on
a process-wide setting.
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn build(query: &str, exact: bool, extended: bool, case: Case) -> Pattern
pub fn build(query: &str, exact: bool, extended: bool, case: Case) -> Pattern
fzf’s BuildPattern (pattern.go:79). exact is -e/--exact,
extended is -x/+x, case is -i/+i/--smart-case.
Sourcepub fn build_with(
query: &str,
exact: bool,
extended: bool,
case: Case,
scheme: Scheme,
) -> Pattern
pub fn build_with( query: &str, exact: bool, extended: bool, case: Case, scheme: Scheme, ) -> Pattern
Pattern::build under an explicit --scheme.
Sourcepub fn build_ranked(
query: &str,
exact: bool,
extended: bool,
case: Case,
scheme: Scheme,
criteria: &[Criterion],
) -> Pattern
pub fn build_ranked( query: &str, exact: bool, extended: bool, case: Case, scheme: Scheme, criteria: &[Criterion], ) -> Pattern
Pattern::build_with told which --tiebreak criteria the ranking will
use, so the matchers can scan in the direction those criteria need.
Sourcepub fn build_full(
query: &str,
exact: bool,
extended: bool,
case: Case,
scheme: Scheme,
criteria: &[Criterion],
algo_v1: bool,
) -> Pattern
pub fn build_full( query: &str, exact: bool, extended: bool, case: Case, scheme: Scheme, criteria: &[Criterion], algo_v1: bool, ) -> Pattern
Pattern::build_ranked with --algo chosen too.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
fzf’s Pattern.IsEmpty (pattern.go:252) — an empty query matches
everything, and the picker shows the stream untouched.
Sourcepub fn score(&self, line: &str) -> Option<i32>
pub fn score(&self, line: &str) -> Option<i32>
The score for one line, or None when the line does not match. This is
fzf’s MatchItem (pattern.go:388) reduced to the score — the offsets it
also returns drive highlighting, which Pattern::positions handles.
Sourcepub fn positions(&self, line: &str) -> Vec<usize>
pub fn positions(&self, line: &str) -> Vec<usize>
The character indices this pattern matched, for fzf’s highlight. Sorted and deduplicated: an OR set can match overlapping runs.
Sourcepub fn match_line(&self, line: &str) -> Option<Bounds>
pub fn match_line(&self, line: &str) -> Option<Bounds>
The score AND the match bounds for one line — fzf’s MatchItem in full.
Pattern::score is this with the bounds dropped; the tiebreak criteria
need them, because begin, end, chunk and pathname all rank by
WHERE the match landed rather than how well it scored.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Pattern
impl Freeze for Pattern
impl Move for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnsafeUnpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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