How to execute Rust code directly on Unix systems? (using the shebang)
<p>From reading <a href="https://github.com/rust-lang/rust/issues/1772#event-16049860" rel="noreferrer">this thread</a>, it looks like its possible to use the shebang to run Rust *.</p>

<pre><code>#!/usr/bin/env rustc

fn main() {
    println!("Hello World!");
}
</code></pre>

<p>Making this executable and running does compile, but not run the code.</p>

<pre><code>chmod +x hello_world.rs
./hello_world.rs
</code></pre>

<p>However this only compiles the code into <code>hello_world</code>.</p>

<p>Can <code>*.rs</code> files be executed directly, similar to a shell script?</p>

<hr>

<p>* This references <a href="https://github.com/killerswan/rustx" rel="noreferrer">rustx</a>, I looked into this, but its a bash script which compiles the script every time (without caching) and never removes the file from the temp directory, although this could be improved. Also it has the significant limitation that it can't use crates.</p>