Struct GlobSet

struct GlobSet { ... }

GlobSet represents a group of globs that can be matched together in a single pass.

Implementations

impl GlobSet

fn builder() -> GlobSetBuilder

Create a new GlobSetBuilder. A GlobSetBuilder can be used to add new patterns. Once all patterns have been added, build should be called to produce a GlobSet, which can then be used for matching.

const fn empty() -> GlobSet

Create an empty GlobSet. An empty set matches nothing.

fn is_empty(self: &Self) -> bool

Returns true if this set is empty, and therefore matches nothing.

fn len(self: &Self) -> usize

Returns the number of globs in this set.

fn is_match<P: AsRef<Path>>(self: &Self, path: P) -> bool

Returns true if any glob in this set matches the path given.

fn is_match_candidate(self: &Self, path: &Candidate<'_>) -> bool

Returns true if any glob in this set matches the path given.

This takes a Candidate as input, which can be used to amortize the cost of preparing a path for matching.

fn matches_all<P: AsRef<Path>>(self: &Self, path: P) -> bool

Returns true if all globs in this set match the path given.

This will return true if the set of globs is empty, as in that case all 0 of the globs will match.

use globset::{Glob, GlobSetBuilder};

let mut builder = GlobSetBuilder::new();
builder.add(Glob::new("src/*").unwrap());
builder.add(Glob::new("**/*.rs").unwrap());
let set = builder.build().unwrap();

assert!(set.matches_all("src/foo.rs"));
assert!(!set.matches_all("src/bar.c"));
assert!(!set.matches_all("test.rs"));
fn matches_all_candidate(self: &Self, path: &Candidate<'_>) -> bool

Returns ture if all globs in this set match the path given.

This takes a Candidate as input, which can be used to amortize the cost of peparing a path for matching.

This will return true if the set of globs is empty, as in that case all 0 of the globs will match.

fn matches<P: AsRef<Path>>(self: &Self, path: P) -> Vec<usize>

Returns the sequence number of every glob pattern that matches the given path.

fn matches_candidate(self: &Self, path: &Candidate<'_>) -> Vec<usize>

Returns the sequence number of every glob pattern that matches the given path.

This takes a Candidate as input, which can be used to amortize the cost of preparing a path for matching.

fn matches_into<P: AsRef<Path>>(self: &Self, path: P, into: &mut Vec<usize>)

Adds the sequence number of every glob pattern that matches the given path to the vec given.

into is cleared before matching begins, and contains the set of sequence numbers (in ascending order) after matching ends. If no globs were matched, then into will be empty.

fn matches_candidate_into(self: &Self, path: &Candidate<'_>, into: &mut Vec<usize>)

Adds the sequence number of every glob pattern that matches the given path to the vec given.

into is cleared before matching begins, and contains the set of sequence numbers (in ascending order) after matching ends. If no globs were matched, then into will be empty.

This takes a Candidate as input, which can be used to amortize the cost of preparing a path for matching.

fn new<I, G>(globs: I) -> Result<GlobSet, Error>
where
    I: IntoIterator<Item = G>,
    G: AsRef<Glob>

Builds a new matcher from a collection of Glob patterns.

Once a matcher is built, no new patterns can be added to it.

impl Clone for GlobSet

fn clone(self: &Self) -> GlobSet

impl Debug for GlobSet

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

impl Default for GlobSet

fn default() -> Self

Create a default empty GlobSet.

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

impl<T> Any for GlobSet

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for GlobSet

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for GlobSet

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

impl<T> CloneToUninit for GlobSet

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

impl<T> From for GlobSet

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for GlobSet

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for GlobSet

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for GlobSet

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

impl<T, U> TryInto for GlobSet

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