百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
I

include_dir

> 编程语言
开源

include_str 宏的逻辑演进,可将目录树嵌入到二进制文件中。

395 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

include_str 宏的逻辑演进,可将目录树嵌入到二进制文件中。

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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

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