mod_idiom
mod and use idiom.
The author of this crate is not good at English.
Forgive me if the document is hard to read.
What is this?
This crate provides a macro for common usage of mod and use.
Background
In Rust, when dividing code into multiple files, first treat the files as
modules with mod, and then access each item inside the module with use.
This approach is very flexible.
However, this approach will be redundant, if you just want to separate items into files and do not plan to access them as modules from multiple locations. In this case, file name is required twice.
Examples
Without this crate.
pub use *;
With this crate.
u!
Note: m is shorthand by Cargo.toml.
Other options
There are many crates that can do the same thing.
Followings are some of them.
📦 mod_use - Supports bulk targeting.
📦 moddef - Supports bulk targeting, public level adjustment, etc.
📦 export-magic - Supports public level adjustment.
Highlights
This crate has no functional advantages compared to others.
(Furthermore, this crate does not support bulk targeting.)
Therefore the rest is all about names and notation.
In other words, it's just a matter of style preference.
I hope this crate fits your style...
TIPS (shorthand name)
Item imports are boilerplate, so you'll want to keep them short.
This can be achieved by changing crate name when introducing it in
Cargo.toml as follows.
[]
= { = "mod_idiom", = "0.1" }
History
See CHANGELOG.