pub struct Pathspec { /* private fields */ }Expand description
A compiled pathspec for matching file paths.
Supports glob patterns like:
*.rs- matches any .rs file in any directorysrc/*.ts- matches .ts files directly in src/src/**/*.ts- matches .ts files anywhere under src/{foo,bar}.js- matches foo.js or bar.js
Implementations§
Source§impl Pathspec
impl Pathspec
Sourcepub fn new(patterns: &[&str]) -> Result<Self>
pub fn new(patterns: &[&str]) -> Result<Self>
Create a new pathspec from patterns.
Empty patterns = match everything.
§Pattern normalization
.or./matches everything (**)- Trailing
/matches everything under that directory (src/**) - If pattern has no
/, treat as**/{pattern}(match anywhere) - Path separators normalized to
/ - Patterns with
..are rejected
§Errors
Returns VoidError::InvalidPattern if any pattern is invalid.
Sourcepub fn could_match_prefix(&self, prefix: &str) -> bool
pub fn could_match_prefix(&self, prefix: &str) -> bool
Check if any path with this prefix could match.
Used for early directory pruning during walks. Returns true if there’s any possibility that a file under this prefix could match the pathspec.
Sourcepub fn matches_all(&self) -> bool
pub fn matches_all(&self) -> bool
Returns true if this matches everything (empty pattern set).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pathspec
impl RefUnwindSafe for Pathspec
impl Send for Pathspec
impl Sync for Pathspec
impl Unpin for Pathspec
impl UnsafeUnpin for Pathspec
impl UnwindSafe for Pathspec
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
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>
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 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>
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