#glob #gitignore #pattern #file #ignore


A fast library for efficiently matching ignore files such as .gitignore against file paths

20 releases

0.4.4 Sep 7, 2018
0.4.3 Jul 28, 2018
0.4.2 Apr 21, 2018
0.4.1 Feb 21, 2018
0.1.5 Nov 10, 2016

#7 in Filesystem

Download history 9985/week @ 2018-08-19 11463/week @ 2018-08-26 10778/week @ 2018-09-02 11813/week @ 2018-09-09 14627/week @ 2018-09-16 12864/week @ 2018-09-23 12402/week @ 2018-09-30 15679/week @ 2018-10-07 13302/week @ 2018-10-14 13154/week @ 2018-10-21 11942/week @ 2018-10-28 12456/week @ 2018-11-04 11825/week @ 2018-11-11

47,477 downloads per month
Used in 71 crates (33 directly)


5.5K SLoC


The ignore crate provides a fast recursive directory iterator that respects various filters such as globs, file types and .gitignore files. This crate also provides lower level direct access to gitignore and file type matchers.

Linux build status Windows build status

Dual-licensed under MIT or the UNLICENSE.




Add this to your Cargo.toml:

ignore = "0.4"

and this to your crate root:

extern crate ignore;


This example shows the most basic usage of this crate. This code will recursively traverse the current directory while automatically filtering out files and directories according to ignore globs found in files like .ignore and .gitignore:

use ignore::Walk;

for result in Walk::new("./") {
    // Each item yielded by the iterator is either a directory entry or an
    // error, so either print the path or the error.
    match result {
        Ok(entry) => println!("{}", entry.path().display()),
        Err(err) => println!("ERROR: {}", err),

Example: advanced

By default, the recursive directory iterator will ignore hidden files and directories. This can be disabled by building the iterator with WalkBuilder:

use ignore::WalkBuilder;

for result in WalkBuilder::new("./").hidden(false).build() {
    println!("{:?}", result);

See the documentation for WalkBuilder for many other options.


~61K SLoC