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

cargo-modules

> 包管理
开源

可视化/分析 Rust 容器的内部结构

1.3K stars0 点赞6 次浏览
访问官网GitHub

工具介绍

可视化/分析 Rust 容器的内部结构

cargo-modules

概述

一个用于可视化/分析箱体内部结构的货物插件。

理由

随着时间的推移,随着您的 Rust 项目变得越来越大,适当地构建代码就变得越来越重要。 幸运的是, Rust 提供了一个非常先进的模块系统,使我们可以将我们的程序框架精确地分割成任意小的子模块,这些子模块包含类型和函数。 虽然这有助于避免单一的和非结构化的代码块,但有时也会使人难以在心中保持对当前项目的整体高级结构的了解。 这就是 cargo-modules 发挥作用的地方:

安装

通过以下方式安装 cargo-modules:

bash
cargo install cargo-modules

使用方法

cargo-modules 工具附带了一些命令:

bash
# Print a crate's hierarchical structure as a tree:
cargo modules structure 

# Print a crate's internal dependencies as a graph:
cargo modules dependencies 

# Detect unlinked source files within a crate's directory:
cargo modules orphans 

命令帮助

terminal
$ cargo modules --help

Visualize/analyze a crate's internal structure.

Usage: cargo-modules 

Commands:
  structure     Prints a crate's hierarchical structure as a tree.
  dependencies  Prints a crate's internal dependencies as a graph.
  orphans       Detects unlinked source files within a crate's directory.
  help          Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

cargo 模块结构

以树状结构打印货柜的层次结构:

bash
cargo modules structure 

命令帮助

…

示例: 以文本树形式表示模块结构

bash
cd ./tests/projects/readme_tree_example
cargo-modules structure --cfg-test

输出:

rust
crate readme_tree_example
├── trait Lorem: pub
├── mod amet: pub(crate)
│   └── mod consectetur: pub(self)
│       └── mod adipiscing: pub(self)
│           └── union Elit: pub(in crate::amet)
├── mod dolor: pub(crate)
│   └── enum Sit: pub(crate)
└── mod tests: pub(crate) #[cfg(test)]
    └── fn it_works: pub(self) #[test]

(项目源代码: [readme_tree_example/src/lib.rs](.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

Rustcargo-commandscode-analysis-tooldeveloper-toolsrust

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

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类包管理
定价开源

> 相关工具

N
npm
Node.js 默认包管理器
P
pnpm
高效节省磁盘的 Node 包管理器
I
is-gif
Check if a Buffer/Uint8Array is a GIF image