How to Use Cargo Aliases and Custom Commands

Define Cargo aliases in .cargo/config.toml to create custom shortcuts for complex build commands.

You define Cargo aliases and custom commands in the [alias] section of your .cargo/config.toml file. Add an entry mapping your desired command name to a cargo subcommand with its arguments.

# .cargo/config.toml
[alias]
test = "test --lib"
build = "build --release"

Now you can run cargo test to execute cargo test --lib and cargo build to execute cargo build --release.