Struct gitignore::Pattern [] [src]

pub struct Pattern<'c> {
    pub pattern: Pattern,
    pub anchored: bool,
    pub negation: bool,
    // some fields omitted

A pattern as found in a .gitignore file.


The glob pattern after being parsed, negation or trailing directory slashes removed, and the root prepended if anchored.

Whether the pattern had the root prepended so the matches must be within the root directory. That is to say, whether the pattern was anchored to the root.

Whether the pattern should, if it matches, negate any previously matching patterns. This flag has no effect if no previous patterns had matched.


impl<'c> Pattern<'c>

Create a new pattern from the raw glob as found in a .gitignore file.

The value of root must be an absolute path.

Returns true if the given path is matched by the current pattern, and hence would be excluded if found in a .gitignore file. The second argument, directory, is a bool representing whether the given path is a directory - if so, it should be set to true, otherwise false if not (eg. file, special file, symlink).

Note that if the glob was negated (ie. of the format ! some/glob/*.here) then this will return the opposite value, eg. false if the pattern matched, and true if the pattern did not match.

The value of path must be an absolute path.

Trait Implementations

impl<'c> Debug for Pattern<'c>

Formats the value using the given formatter.