Crates.io | cargo-minify |
lib.rs | cargo-minify |
version | 0.5.0 |
source | src |
created_at | 2023-12-01 12:51:42.379314 |
updated_at | 2023-12-01 12:51:42.379314 |
description | A cargo utility to automatically remove unused code from a Rust project. |
homepage | https://github.com/tweedegolf/cargo-minify |
repository | https://github.com/tweedegolf/cargo-minify |
max_upload_size | |
id | 1055047 |
size | 71,164 |
Remove unused code from your Rust programs. Primarily aimed at generated code (prime example: bindings generated by bindgen), but also usable in more general context.
Public functions and types in libraries (which makes sense) but also in binaries and examples are not considered unused,
as well as code that is explicitly allowed to be unused (using #[allow(unused)]
).
git clone git@github.com:tweedegolf/cargo-minify.git
cargo install --path cargo-minify
After installation, you can run this tool by simply typing cargo minify
from your crate root.
This runs it on your project and will print out any changes that will be made to your code.
To actually apply these changes, you have to run cargo minify --apply
.
You can perform a more precise minifcation by using the --ignore
option, followed by a
wildcard specification. Unused code in the excluded files will not be touched. You can also you
the --kinds
flag to specify which types of unused code to remove. Supported are:
FUNCTION
, which will remove unused function defintionsASSOCIATED_FUNCTION
, which will remove unused associated functions from impl
blocksSTRUCT
, ENUM
, UNION
, which will remove unused type definitions of said typeTYPE_ALIAS
, which removes unused type aliasesCONST
, which will remove unused constantsSTATIC
, which will remove unused static variablesWithout any --kinds
specification, all of the above will be removed.
cargo minify --apply
expects your files to be under control of version control; if this is not
the case a warning will be given and no changes will be made; this can be overridden using the
--allow-no-vcs
, --allow-dirty
, and --allow-staged
flags.
Of course you can also view this information (and other options) by running cargo minify --help
.
Still to add to cargo minify
:
static
variables.Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.