The Rust CheatSheet

The only thing you need to know about Rust is that it's a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.

Getting Started

Hello, World

fn main() {
    println!("Hello, world!");
}

Compiling and running

$ rustc hello-world.rs
$ ./hello-world
Hello, world!

Using Cargo

cargo new hello-world

Building and running

cargo run

Output

   Compiling hello-world v0.1.0 (/home/dev/Desktop/hello-world)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.26s
     Running `target/debug/hello-world`
Hello, world!

Primitive Types

bool

Boolean (true/false)

char

Character

f32, f64

32-bits, 64-bits floats

i64, i32, i16, i8

Signed 16- ... integers

u64, u32, u16, u8

Unsigned 16-bits, ... integers

isize

Pointer-sized signed integers

usize

Pointer-sized unsigned integers