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
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
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Rust,
- Rust: Cargo Init vs Cargo New Command
- Rust: Write and Run Hello World! Program Example
- How to Split a String using Rust Language
- How to Sort a Vector in Rust with Examples
- Fix: error: could not find `Cargo.toml` in Users or any parent directory
- How to uninstall Rust Language from Mac/Linux/Ubuntu
- How to update Cargo (Rust Lang)
- Fix: rust-analyzer failed to discover workspace [Visual Studio Code]
- How to install Rust using rustup on macOS/Linux/Ubuntu
- Cargo Watch: To Recompile Rust Project Automatically
- Difference between rustc and cargo build commands
- How to Split a String by Space in Rust
- How to know Rust is Installed on Mac?
- Rust: zsh: no such file or directory: ./main
- How to update Rust on Mac/Linux
- List of Rust Cargo Commands
- How to find version of Cargo in Rust
- Fix: error: mismatched closing delimiter } [Rust]
More Posts:
- [Program] How to read three different values using Scanner in Java - Java
- Xcode 13 - unknown error compiling for iOS 15.0 but module has a minimum deployment target of iOS 15.2 - iOS
- Fix: Mac Screenshot opens in Mail Application - MacOS
- [fix] zsh: command not found: telnet on Mac - MacOS
- pip get list of all outdated Python packages - Python
- 5 Reasons Why Jupyter Notebook is Not Opening and Solutions - Python
- How to wrap column text in SharePoint Online Modern List Grid View using JSON formatting - SharePoint
- Java: Print Stack Trace as String Without Exception - Java