#glob #ignore #gitignore #pattern #file


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

22 releases

0.4.6 Dec 30, 2018
0.4.4 Sep 7, 2018
0.4.3 Jul 28, 2018
0.4.1 Feb 21, 2018
0.1.5 Nov 10, 2016

#8 in Filesystem

Download history 11975/week @ 2018-10-11 13753/week @ 2018-10-18 11416/week @ 2018-10-25 12850/week @ 2018-11-01 12076/week @ 2018-11-08 13209/week @ 2018-11-15 12425/week @ 2018-11-22 10690/week @ 2018-11-29 12539/week @ 2018-12-06 13183/week @ 2018-12-13 13663/week @ 2018-12-20 11035/week @ 2018-12-27 10071/week @ 2019-01-03

52,956 downloads per month
Used in 86 crates (39 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.


~62K SLoC