Skip to main content

CompiledPattern

Enum CompiledPattern 

Source
pub enum CompiledPattern {
    MatchAll,
    RootFilesOnly,
    ExtensionSuffix(String),
    SingleSegmentGlob(String),
    MultiSegmentGlob(String),
    AnchoredDirectory(String),
    UnanchoredDirectory(String),
    Exact(String),
}
Expand description

A CODEOWNERS pattern, pre-processed for repeated fast matching.

Use CompiledPattern::new to compile, then CompiledPattern::matches to match paths. Construction is O(pattern length); matching is close to O(path length) for all variants except the glob ones.

Variants§

§

MatchAll

Matches everything (unanchored * or **).

§

RootFilesOnly

Anchored /* — matches only root-level files (no slashes in path).

§

ExtensionSuffix(String)

Extension suffix like .rs (from *.rs) — simple ends_with check.

Stored as the literal suffix including the leading dot. Matcher also verifies there is a / immediately before the suffix to avoid false positives like notrs matching .rs.

§

SingleSegmentGlob(String)

Single-segment glob like *.rs that fell out of the extension fast-path — matched via fast_glob with a prepended **/ so it triggers in any directory.

§

MultiSegmentGlob(String)

Multi-segment glob like src/**/*.rs — matched directly via fast_glob.

§

AnchoredDirectory(String)

Anchored directory pattern like /src/ — matches a prefix at the root only.

§

UnanchoredDirectory(String)

Unanchored directory pattern like docs/ — matches anywhere in the tree.

§

Exact(String)

An exact path, always anchored (no wildcards, no trailing slash).

Implementations§

Source§

impl CompiledPattern

Source

pub fn new(pattern: &str) -> Self

Compile a CODEOWNERS pattern string into a specialized matcher.

The leading / (anchor) is inspected to distinguish anchored from unanchored directory patterns; a trailing / selects directory matching over exact matching.

Source

pub fn matches(&self, path: &str) -> bool

Test whether path matches this pattern.

Empty paths never match. Pattern semantics follow GitHub’s CODEOWNERS rules (last match wins is handled by the caller — see check_file_ownership_parsed).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.