Rust — Command Reference
Rust's most used commands — memory safety and performance combined. Each example is a complete program (fn main). Each includes an explanation and a working example.
8 categories · 22 commands
🖥️
Output
println! macro and formatting.
println!format!{:?} (debug)📦
Variables
let, mut, const, and shadowing.
let / let mutconstShadowing🔢
Numbers & Math
Arithmetic, methods, and type casting (as).
Arithmetic ( + - * / % )as (type casting)pow / sqrt✍️
String
&str, String, and text methods.
String / &strto_uppercase / containssplit📋
Vector & HashMap
Flexible lists (Vec) and key-value pairs (HashMap).
Veciter / map / sumHashMap🔁
Condition & Loop
if, match, and loops.
if / elsematchfor (range)while / loop🧩
Function
Function definition with fn.
fn🔑
Ownership & Borrowing
Rust's signature feature: memory safety.
OwnershipBorrowing ( & )