Create Script to Compile and Execute Rust Programs
Create a file called rustrun in your /usr/local/bin directory that contains the following:
#!/usr/local/bin/bash
rustc $1.rs && ./$1
This assumes you have installed bash on your system and that /usr/local/bin is in your PATH, which you can verify via:
$ echo $PATH
Then run:
$ sudo chmod u+x rustrun
Ensure that when your run ls -all rustrun you see:
-rwxr-xr-x 1 root wheel 42 Feb 24 09:28 rustrun
If not, run sudo chmod +x rustrun
Then, when you are done writing your Rust program in whatever directory you're working in, you can just run
$ rustrun helloworld
Note: You don't need to include the .rs extension
Note: I changed the line to now read rustc $1 && ./${1::-3} which strips off the extension when running the executable. This now means you do need to add the .rs extension when running the command