pub struct MatchGroup<T: Pattern = Attributes> {
    pub patterns: Vec<PatternList<T>>,
}
Expand description

A grouping of lists of patterns while possibly keeping associated to their base path.

Pattern lists with base path are queryable relative to that base, otherwise they are relative to the repository root.

Fields§

§patterns: Vec<PatternList<T>>

A list of pattern lists, each representing a patterns from a file or specified by hand, in the order they were specified in.

During matching, this order is reversed.

Implementations§

source§

impl<T> MatchGroup<T>where T: Pattern,

source

pub fn pattern_matching_relative_path<'a>( &self, relative_path: impl Into<&'a BStr>, is_dir: Option<bool>, case: Case ) -> Option<Match<'_, T::Value>>

Match relative_path, a path relative to the repository containing all patterns, and return the first match if available.

source§

impl MatchGroup<Ignore>

source

pub fn from_git_dir( git_dir: impl AsRef<Path>, excludes_file: Option<PathBuf>, buf: &mut Vec<u8> ) -> Result<Self>

Given git_dir, a .git repository, load ignore patterns from info/exclude and from excludes_file if it is provided. Note that it’s not considered an error if the provided excludes_file does not exist.

source

pub fn from_overrides( patterns: impl IntoIterator<Item = impl Into<OsString>> ) -> Self

source

pub fn add_patterns_file( &mut self, source: impl Into<PathBuf>, follow_symlinks: bool, root: Option<&Path>, buf: &mut Vec<u8> ) -> Result<bool>

Add the given file at source if it exists, otherwise do nothing. If a root is provided, it’s not considered a global file anymore. Returns true if the file was added, or false if it didn’t exist.

source

pub fn add_patterns_buffer( &mut self, bytes: &[u8], source: impl Into<PathBuf>, root: Option<&Path> )

Add patterns as parsed from bytes, providing their source path and possibly their root path, the path they are relative to. This also means that source is contained within root if root is provided.

Trait Implementations§

source§

impl<T: Clone + Pattern> Clone for MatchGroup<T>

source§

fn clone(&self) -> MatchGroup<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + Pattern> Debug for MatchGroup<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T: Default + Pattern> Default for MatchGroup<T>

source§

fn default() -> MatchGroup<T>

Returns the “default value” for a type. Read more
source§

impl<T: Hash + Pattern> Hash for MatchGroup<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: Ord + Pattern> Ord for MatchGroup<T>

source§

fn cmp(&self, other: &MatchGroup<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<T: PartialEq + Pattern> PartialEq<MatchGroup<T>> for MatchGroup<T>

source§

fn eq(&self, other: &MatchGroup<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd + Pattern> PartialOrd<MatchGroup<T>> for MatchGroup<T>

source§

fn partial_cmp(&self, other: &MatchGroup<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: Eq + Pattern> Eq for MatchGroup<T>

source§

impl<T: Pattern> StructuralEq for MatchGroup<T>

source§

impl<T: Pattern> StructuralPartialEq for MatchGroup<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for MatchGroup<T>where <T as Pattern>::Value: RefUnwindSafe,

§

impl<T> Send for MatchGroup<T>where <T as Pattern>::Value: Send,

§

impl<T> Sync for MatchGroup<T>where <T as Pattern>::Value: Sync,

§

impl<T> Unpin for MatchGroup<T>where <T as Pattern>::Value: Unpin,

§

impl<T> UnwindSafe for MatchGroup<T>where <T as Pattern>::Value: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.