cargo-watch is a tool that allows to automatically recompile Rust project whenever there is a change in the Rust source code.
How to install cargo-watch
cargo install cargo-watch
Logs:
Updating crates.io index
Downloaded cargo-watch v8.4.0
Downloaded 1 crate (171.1 KB) in 0.74s
Installing cargo-watch v8.4.0
....
Compiling cargo-watch v8.4.0
Finished release [optimized] target(s) in 51.38s
Installing /Users/c2ctech/.cargo/bin/cargo-watch
Installed package `cargo-watch v8.4.0` (executable `cargo-watch`)
Cargo Watch Usage Examples
Syntax:
1. To Watch Tests
cargo watch -x test
cargo watch -x test 2. To Watch and Run a Binary
cargo watch -x run
3. To Watch Builds
cargo watch -x build
4. To Watch and Build with Release Optimization
cargo watch -x "build --release"
5. To Watch and Run Custom Commands
cargo watch -x "run -- arg1 arg2"
6. To Watch Specific Package
cargo watch -p package-name build
7. To Watch Run Test for Specific Package
cargo watch -p package-name test
8. To Watch an arbitrary command
cargo watch -- echo Hello world
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
cargo watch -x run cargo watch -x build
4. To Watch and Build with Release Optimization
cargo watch -x "build --release"
5. To Watch and Run Custom Commands
cargo watch -x "run -- arg1 arg2"
6. To Watch Specific Package
cargo watch -p package-name build
7. To Watch Run Test for Specific Package
cargo watch -p package-name test
8. To Watch an arbitrary command
cargo watch -- echo Hello world
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
cargo watch -x "build --release" cargo watch -x "run -- arg1 arg2"
6. To Watch Specific Package
cargo watch -p package-name build
7. To Watch Run Test for Specific Package
cargo watch -p package-name test
8. To Watch an arbitrary command
cargo watch -- echo Hello world
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
cargo watch -p package-name build cargo watch -p package-name test
8. To Watch an arbitrary command
cargo watch -- echo Hello world
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
cargo watch -- echo Hello worldProvide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!