Rust
Last updated: 2024, Mon Jun 3rd at 13:48 CDT
Rust general-purpose programming language that emphasizes performance. It is a lower-level general-purpose programming language featuring memory safety, thread safety, cross-platform support, and zero-cost abstractions.
/* genrates a number 1-20 10 times */
use rand::distributions::{Distribution, Uniform};
fn main() {
let roll = 10;
let dice = 20;
let mut rng = rand::thread_rng();
let die = Uniform::from(1..dice+1);
let mut i = 0;
while i < roll {
let throw = die.sample(&mut rng);
println!("die: {}", throw);
i = i + 1;
}
}
To Install: #
Preferred method
The easiest way to Install Rust and Cargo is to install the current stable release of Rust using rustup. Installing Rust using rustup will also install
cargo
.
sudo pacman -S rustup
AUR: rustup-git
sudo apt install rustup
sudo dnf install rustup
sudo zypper in rustup
Additional install options
The official way of installing rustup on Linux is
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
It will download a script, and start the installation. If everything goes well, you’ll see this appear:
Rust is installed now. Great!
Extras #
Enable tab completion:
Bash
rustup completions bash > ~/.local/share/bash-completion/completions/rustup
Fish
mkdir -p ~/.config/fish/completions rustup completions fish > ~/.config/fish/completions/rustup.fish
zsh
rustup completions zsh > ~/.zfunc/_rustup