Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Run A Single File As A Script With Rust

Code

#!/usr/bin/env cargo +nightly -Zscript

```cargo
[dependencies]
rand = "0.8.5"
```

use rand::prelude::*;

fn main() {
    let mut rng = rand::thread_rng();
    let num: u8 = rng.gen();
    println!("Random number: {}", num); 
}

Results

Random number: 230

References