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

automod

> 编程语言
开源

将目录中的每个源文件作为模块拉入

187 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

将目录中的每个源文件作为模块拉入

Automod

(This project is no longer maintained.)

Pull in every source file in a directory as a module.

toml
[dependencies]
automod = "1.0"

Syntax

rust
automod::dir!("path/to/directory");

This macro expands to one or more mod items, one for each source file in the specified directory, excluding mod.rs, lib.rs, and main.rs.

The path is given relative to the directory containing Cargo.toml.

It is an error if the given directory contains no source files or if a file name is not valid UTF-8.

The macro takes an optional visibility to apply on the generated modules: automod::dir!(pub "path/to/directory").

Example

Suppose that we would like to keep a directory of regression tests for individual numbered issues:

  • tests/
    • regression/
      • issue1.rs
      • issue2.rs
      • ...
      • issue128.rs

We would like to be able to toss files in this directory and have them automatically tested, without listing them in some explicit list of modules. Automod solves this by adding tests/regression.rs containing:

rust
mod regression {
    automod::dir!("tests/regression");
}

The macro invocation expands to:

rust
mod issue1;
mod issue2;
/* ... */
mod issue128;

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

Rust

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

> 工具信息

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

> 相关工具

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