Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Get A Random Element From A Vec In Rust

rust
```cargo
[dependencies]
rand = "0.8"
```

use rand::thread_rng;
use rand::seq::SliceRandom;

fn main() {
  let items = vec!["alfa", "bravo", "charlie", "delta"];
  let mut rng = thread_rng();
  match items.choose(&mut rng) {
    Some(item) => println!("{}", item),
    None => println!("No items in vec")
  }
}
results start

This is how I'm getting random items from a Vec in Rust.