Avatar ·

How to set up automatic recompilation of a Rust project when files change?

Hello everyone! I'm new to Rust and use Cargo for building projects. It's very annoying that after every code change I have to manually run cargo build or cargo run. I'm used to automatic recompilation in other languages (for example, in Node.js with nodemon or in Python with --reload).

\n\n

Here's my typical workflow:

\n\n
// main.rs\nfn main() {\n    println!("Hello, world!");\n}\n
\n\n

I edit the file, save it, then run to the terminal and type cargo run. This takes time and disrupts the flow of thoughts. I've heard there are tools like cargo-watch, but I'm not sure how to properly install and use them.

\n\n

Please tell me how to set up automatic recompilation and re-