cargo-run - Run the current package
Run a binary or example of the local package.
All the arguments following the two dashes (--
) are passed to the binary to
run. If you’re passing arguments to both Cargo and the binary, the ones after
--
go to the binary, the ones before go to Cargo.
When no target selection options are given, cargo run
will run the binary
target. If there are multiple binary targets, you must pass a target flag to
choose one. Or, the default-run
field may be specified in the [package]
section of Cargo.toml
to choose the name of the binary to run by default.
- --bin NAME
-
Run the specified binary.
- --example NAME
-
Run the specified example.
-
Build the local package and run its main target (assuming only one binary):
cargo run
-
Run an example with extra arguments:
cargo run --example exname -- --exoption exarg1 exarg2