Languages
Rust
Introduction

Introduction

Why Rust?

Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.

Install Rust into Arch Linux

sudo pacman -S rust
 
# check version
rustc --version

How to use Rust

Create a new project

cargo new hello-rust
cd hello-rust

Cargo commands

Build and run

cargo build
cargo run

Cargo watch

cargo install cargo-watch # install cargo-watch
sudo pacman -S cargo-watch # install cargo-watch
cargo watch -x run

Build for release

cargo build --release

Build and run tests

cargo test

Build and run benchmarks

cargo bench

Build and run documentation

cargo doc --open

Build and run clippy

cargo clippy

Build and run rustfmt

cargo fmt

Build and run rustfix

cargo fix

Build and run rust-analyzer

cargo xtask install --server

Build and run cargo-audit

cargo audit