Live reloading in Rust

Live reloading in Rust

ยท

2 min read

I've been learning Rust on and off since last fall. I'm still not proficient in the language as I haven't dedicated as much time to the language as I'd like to. Still, I find pockets of time, like tonight, to dive in a bit.

A quick Google of "rust hot reloading" introduced me to the rust crate, cargo-watch. I installed it as per their instructions cargo install cargo-watch.

From there, I went into a rust project I'm working on and ran the following from the project's root from the command line, cargo watch -x 'run'.

And that was it! I was able to start up my program, and with every change, it reran automatically!

[Finished running. Exit status: 101]
[Running 'cargo run']
   Compiling rusty v0.1.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/rusty`
["tobey maguire", "andrew garfield", "tom holland"]
[Finished running. Exit status: 0]
[Running 'cargo run']
   Compiling rusty v0.1.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/rusty`
["tobey maguire", "andrew garfield", "tom holland", ""]
[Finished running. Exit status: 0]
[Running 'cargo run']
   Compiling rusty v0.1.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/rusty`
["tobey maguire", "andrew garfield", "tom holland", "pete davidson"]
[Finished running. Exit status: 0]

๐Ÿฆ€

Photo by Mackenzie Cruz on Unsplash

Other places you can find me at:

๐ŸŽฌ YouTube
๐ŸŽฌ Twitch
๐ŸŽฌ nickyt.live
๐Ÿ’ป GitHub
๐Ÿ‘พ My Discord
๐Ÿฆ Twitter/X
๐Ÿงต Threads
๐ŸŽ™ My Podcast
๐Ÿ—ž๏ธ One Tip a Week Newsletter
๐ŸŒ My Website

ย