pub struct GlobSet { /* private fields */ }Expand description
A set of glob patterns that can be matched against paths efficiently.
GlobSet classifies each pattern at build time into the fastest applicable
strategy (extension hash, literal, prefix, suffix) and only falls back to
the full glob_match engine for patterns that need it.
§Example
use glob_set::{Glob, GlobSet, GlobSetBuilder};
let mut builder = GlobSetBuilder::new();
builder.add(Glob::new("*.rs").unwrap());
builder.add(Glob::new("*.toml").unwrap());
let set = builder.build().unwrap();
assert!(set.is_match("foo.rs"));
assert!(set.is_match("Cargo.toml"));
assert!(!set.is_match("foo.js"));Implementations§
Source§impl GlobSet
impl GlobSet
Sourcepub fn is_match(&self, path: impl AsRef<str>) -> bool
pub fn is_match(&self, path: impl AsRef<str>) -> bool
Test whether any pattern matches the given path.
Sourcepub fn is_match_candidate(&self, candidate: &Candidate<'_>) -> bool
pub fn is_match_candidate(&self, candidate: &Candidate<'_>) -> bool
Test whether any pattern matches the given candidate.
Sourcepub fn matches(&self, path: impl AsRef<str>) -> Vec<usize>
pub fn matches(&self, path: impl AsRef<str>) -> Vec<usize>
Return the indices of all patterns that match the given path.
Sourcepub fn matches_into(&self, path: impl AsRef<str>, into: &mut Vec<usize>)
pub fn matches_into(&self, path: impl AsRef<str>, into: &mut Vec<usize>)
Append the indices of all matching patterns to into.
Sourcepub fn matches_candidate(&self, candidate: &Candidate<'_>) -> Vec<usize>
pub fn matches_candidate(&self, candidate: &Candidate<'_>) -> Vec<usize>
Return the indices of all patterns that match the given candidate.
Sourcepub fn matches_candidate_into(
&self,
candidate: &Candidate<'_>,
into: &mut Vec<usize>,
)
pub fn matches_candidate_into( &self, candidate: &Candidate<'_>, into: &mut Vec<usize>, )
Append the indices of all matching patterns for the given candidate to into.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GlobSet
impl RefUnwindSafe for GlobSet
impl Send for GlobSet
impl Sync for GlobSet
impl Unpin for GlobSet
impl UnsafeUnpin for GlobSet
impl UnwindSafe for GlobSet
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
Mutably borrows from an owned value. Read more