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
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
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: - Convert seconds to minutes using JavaScript - JavaScript
- Read a file line by line in Python Program - Python
- How to Enable Developers Option in Android Phones Settings - Android
- Get the Current Date using LocalDate in Java - Java
- [Program] How to read three different values using Scanner in Java - Java
- Check macOS free disk space using Terminal command - MacOS
- How to Fix Spelling Errors on Microsoft Word for Mac - HowTos
- How to detect Operating System using Java code - Java
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
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
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: - Convert seconds to minutes using JavaScript - JavaScript
- Read a file line by line in Python Program - Python
- How to Enable Developers Option in Android Phones Settings - Android
- Get the Current Date using LocalDate in Java - Java
- [Program] How to read three different values using Scanner in Java - Java
- Check macOS free disk space using Terminal command - MacOS
- How to Fix Spelling Errors on Microsoft Word for Mac - HowTos
- How to detect Operating System using Java code - Java
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
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
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: - Convert seconds to minutes using JavaScript - JavaScript
- Read a file line by line in Python Program - Python
- How to Enable Developers Option in Android Phones Settings - Android
- Get the Current Date using LocalDate in Java - Java
- [Program] How to read three different values using Scanner in Java - Java
- Check macOS free disk space using Terminal command - MacOS
- How to Fix Spelling Errors on Microsoft Word for Mac - HowTos
- How to detect Operating System using Java code - Java
cargo watch -p package-name build
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!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
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: - Convert seconds to minutes using JavaScript - JavaScript
- Read a file line by line in Python Program - Python
- How to Enable Developers Option in Android Phones Settings - Android
- Get the Current Date using LocalDate in Java - Java
- [Program] How to read three different values using Scanner in Java - Java
- Check macOS free disk space using Terminal command - MacOS
- How to Fix Spelling Errors on Microsoft Word for Mac - HowTos
- How to detect Operating System using Java code - Java
cargo watch -- echo Hello world
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- 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]
- Convert seconds to minutes using JavaScript - JavaScript
- Read a file line by line in Python Program - Python
- How to Enable Developers Option in Android Phones Settings - Android
- Get the Current Date using LocalDate in Java - Java
- [Program] How to read three different values using Scanner in Java - Java
- Check macOS free disk space using Terminal command - MacOS
- How to Fix Spelling Errors on Microsoft Word for Mac - HowTos
- How to detect Operating System using Java code - Java