cargo-modules alternatives and similar packages
Based on the "Cargo" category.
Alternatively, view cargo-modules alternatives based on common mentions on social networks and blogs.
6.7 7.9 cargo-modules VS cargo-releaseCargo subcommand `release`: everything about releasing a rust crate.
2.9 2.9 cargo-modules VS cargo-bitbakecargo extension that can generate BitBake recipes utilizing the classes from meta-rust
Do you think we are missing an alternative of cargo-modules or a related project?
A cargo plugin for showing an overview of a crate's modules.
With time, as your Rust projects grow bigger and bigger, it gets more and more important to properly structure your code. Fortunately Rust provides us with a quite sophisticated module system, allowing us to neatly split up our crates into arbitrarily small sub-modules of types and functions. While this helps to avoid monolithic and unstructured chunks of code, it can also make it hard at times to still mentally stay on top of the over-all high-level structure of the project at hand.
This is where
cargo-modules comes into play:
cargo-modules on nightly via:
cargo install cargo-modules
Or using rustup's ad-hoc mode:
rustup run nightly cargo install cargo-modules
Or if you want to build it locally:
$ rustup run nightly cargo build --release
cargo-modules requires nightly to run.
As such unless you already are using
nightly you need to either run this rustup command once,
to set the default toolchain to
rustup default nightly
… or override the toolchain for the current directory (again, once):
rustup override set nightly
To then be able to just call cargo-modules through:
cargo modules <options>
Or if you want to stay on the
stable toolchain you would have to call cargo-modules through:
rustup run nightly cargo modules <options>
Display module parent-child relationships as a tree:
cargo modules tree
If you also want to see which modules depends on which other modules, you can use graph mode to output Graphviz DOT compatible output:
cargo modules graph
As extra options you can toggle external types/modules, conditional modules and used types using the
--types options respectively.
You can convert the output to a PNG file as below:
cargo modules graph | dot -Tpng > modules.png
- Green nodes are public modules.
- Yellow nodes are private modules.
- Black nodes are external types or modules.
Dotted nodes are conditional (test modules for example).
Black edges denote a 'is sub module of' relation.
Yellow/Green edges denote a 'use something of module' relation
The width of the edge is determined by the number of types used. If types are enabled the edge label shows the types used Green means the use is public, yellow means the use is private.
If you want to also list of potentially orphaned modules,
then add a
cargo modules --orphans tree cargo modules --orphans graph
src/../foo/mod.rs that is not linked by its
mod foo; is considered a (potential) orphaned module.
To keep false positives to a minimum
cargo-modules excludes all build scripts
as well as
main.rs from the selection of potential orphans.
If you, for some reason, need to remove the coloring, use:
cargo modules --plain tree cargo modules --plain graph
If you need any further help:
cargo modules --help
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct,
and the process for submitting pull requests to us.
- Vincent Esche – Initial work – Regexident
See also the list of contributors who participated in this project.
This project is licensed under the MPL-2.0 – see the [LICENSE.md](LICENSE.md) file for details.
*Note that all licence references and agreements mentioned in the cargo-modules README section above are relevant to that project's source code only.