[][src]Struct gitignore::File

pub struct File<'a> { /* fields omitted */ }

Represents a .gitignore file. Use this to load the .gitignore file, parse the patterns, and then check if a given path would be excluded by any rules contained therein.

Examples

let file = gitignore::File::new(&gitignore_path).unwrap();
assert!(file.is_excluded(&path_to_test_if_excluded).unwrap())

Implementations

impl<'b> File<'b>[src]

pub fn new(gitignore_path: &'b Path) -> Result<File<'b>, Error>[src]

Parse the given .gitignore file for patterns, allowing any arbitrary path to be checked against the set of rules to test for exclusion.

The value of gitignore_path must be an absolute path.

pub fn is_excluded(&self, path: &'b Path) -> Result<bool, Error>[src]

Returns true if, after checking against all the patterns found in the .gitignore file, the given path is matched any of the globs (applying negated patterns as expected). Note this function also returns false if the path does not exist.

If the value for path is not absolute, it will assumed to be relative to the current working directory.

pub fn included_files(&self) -> Result<Vec<PathBuf>, Error>[src]

Returns a list of files that are not excluded by the rules in the loaded .gitignore file. It recurses through all subdirectories and returns everything that is not ignored.

Trait Implementations

impl<'a> Debug for File<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for File<'a>

impl<'a> Send for File<'a>

impl<'a> Sync for File<'a>

impl<'a> Unpin for File<'a>

impl<'a> UnwindSafe for File<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.