pub struct ExcludeMatchers {
pub invalid: Vec<(String, String)>,
/* private fields */
}Expand description
Compiled exclude patterns with directory-pattern expansion applied.
Match paths through matched_pattern using a
root-relative path (the CLI relativizes against the project root, the
LSP against the containing workspace root) so patterns like
docs/drafts behave identically everywhere.
Fields§
§invalid: Vec<(String, String)>Patterns that failed to compile, with their errors. Callers decide how to surface these (CLI prints to stderr, LSP logs).
Implementations§
Source§impl ExcludeMatchers
impl ExcludeMatchers
pub fn new(patterns: &[String]) -> Self
pub fn is_empty(&self) -> bool
Sourcepub fn matched_pattern(&self, relative_path: &str) -> Option<&str>
pub fn matched_pattern(&self, relative_path: &str) -> Option<&str>
The first pattern matching relative_path, if any.
pub fn is_match(&self, relative_path: &str) -> bool
Sourcepub fn matched_pattern_for_file(
&self,
relative: Option<&str>,
absolute: &Path,
) -> Option<&str>
pub fn matched_pattern_for_file( &self, relative: Option<&str>, absolute: &Path, ) -> Option<&str>
The first pattern matching a file, if any.
Both forms of the file are tried: its relative form (how patterns are
normally written - relative to the project or workspace root) and its
absolute path, which is what an absolute pattern matches. Absolute
patterns reach config either written literally or through ~ expansion,
and the walker’s overrides cannot apply them (the ignore crate anchors
a leading / to the walk root), so this is where they take effect.
Checking the absolute path cannot widen a relative pattern: globs are
anchored at the start of the matched string, so drafts/** never
matches /home/dev/proj/drafts/note.md.
absolute is canonicalized before matching, since an expanded ~
resolves to a canonical location. Files that cannot be canonicalized
(already deleted, unreadable) are matched as given.
Sourcepub fn excludes_file(&self, relative: Option<&str>, absolute: &Path) -> bool
pub fn excludes_file(&self, relative: Option<&str>, absolute: &Path) -> bool
Whether any pattern matches the file (see matched_pattern_for_file).