Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
I

include_dir

> 编程语言
Open source

The logical evolution of the include_str macro for embedding a directory tree into your binary.

395 stars0 likes0 views
WebsiteGitHub

About

The logical evolution of the include_str macro for embedding a directory tree into your binary.

include_dir

An evolution of the include_str!() and include_bytes!() macros for embedding an entire directory tree into your binary.

Rendered Documentation:

  • master
  • Latest Release

Getting Started

The include_dir!() macro works very similarly to the normal include_str!() and include_bytes!() macros. You pass the macro a file path and assign the returned value to some static variable.

rust
use include_dir::{include_dir, Dir};

static PROJECT_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR");

// of course, you can retrieve a file by its full path
let lib_rs = PROJECT_DIR.get_file("src/lib.rs").unwrap();

// you can also inspect the file's contents
let body = lib_rs.contents_utf8().unwrap();
assert!(body.contains("SOME_INTERESTING_STRING"));

// you can search for files (and directories) using glob patterns
#[cfg(feature = "glob")]
{
    let glob = "**/*.rs";
    for entry in PROJECT_DIR.find(glob).unwrap() {
        println!("Found {}", entry.path().display());
    }
}

Features

  • Embed a directory tree into your binary at compile time
  • Find a file in the embedded directory
  • Search for files using a glob pattern (requires the globs feature)
  • File metadata (requires the metadata feature)

To-Do list:

  • Compression?

Issues· 37 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言