Boost Your Rust 🦀 Development with Hot Reload using cargo-watch

Cloud Native Pilgrim | Kubernetes Enthusiast | Serverless Believer | Customer Experience Architect @ Pulumi | (he/him) | CK{A,AD} |
Search for a command to run...

Cloud Native Pilgrim | Kubernetes Enthusiast | Serverless Believer | Customer Experience Architect @ Pulumi | (he/him) | CK{A,AD} |
No comments yet. Be the first to comment.
Discover the power of Rust - the modern systems programming language - through my insightful blog series. Dive deep into its features, benefits, and examples.
Introduction In this blog article, I want to upgrade my builder pattern implementation in Rust 🦀 using the Typestate pattern. If you are not familiar with the builder pattern or design patterns in general, I highly recommend you to read my previous ...
GPU scheduling in Kubernetes has always felt like buying a mansion when you need a studio apartment. A small inference workload that needs 2GB of GPU memory gets scheduled on an entire 80GB A100, and there's nothing you can do about it. The device pl...

TL;DR: The code https://github.com/dirien/quick-bites Nothing is more controversial in the Kubernetes community than whether to use Helm or Kustomize. I always advocate the philosophy of using the right tool for the right job. It avoids the problem...

TL;DR Le code https://github.com/dirien/quick-bites Introduction This article is part three of my series on secret management on Kubernetes with the help of Pulumi. In my first article, we talked about the Sealed Secrets controller. The second arti...

With AWS Lambda

Disaster Recovery, Data Migration made easy!

Most of the developers with a node.js background are pretty familiar with the package called nodemon.
nodemon is a tool is automatically restarting the node application whenever we change a file in a directory. This is tremendously useful during development, as we don't have to restart the application manually every time we make a change. And as we all know, we developers are lazy!
Or you may be familiar with the tool called entr, which is a command-line tool that runs arbitrary commands when files change.
In this blog article, I will show you a similar command-line tool with the same productivity boost but for Rust. This tool is called cargo-watch.
cargo-watch?cargo-watch watches your Rust project for any changes and runs cargo commands when a change is detected. The installation is very simple, just run the following command:
cargo install cargo-watch
The simplest usage of cargo-watch is to run the cargo run command whenever a file in the current directory changes:
cargo watch -x run
If you want to run multiple commands, you can use the -x flag multiple times. In the following example, we will run the cargo test and cargo run commands whenever a file in the current directory changes:
cargo watch -x test -x run
If you want to suppress the output of the cargo run command, you add the -q flag to the cargo run command:
cargo watch -x test -x 'run -q'
With the -w flag, you can specify a directory to watch. In the following example, we will watch the src directory for changes:
cargo watch -w src/ -x test -x 'run -q'
cargo-watch ignores per default all files and directories listed in the .gitignore file. With the flag --no-vcs-ignores you can disable this behavior. Secondly, cargo-watch ignores all files and directories that are listed in the .ignore file. With the flag --no-dot-ignores you can also disable this behavior.
Additionally, you can ignore files and directories by using the -i flag. This uses the Glob pattern matching syntax.
With cargo-watch we have a similar tool by hand, which we are already familiar from other programming languages.
I use this tool every day and I can highly recommend it! The boost in your development productivity will be huge!