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

Rustfinity.com

Links

  1. Home
  2. Learn Rust
  3. Get Started
  4. Practice Rust
  5. Challenges
  6. Tutorials
  7. Blog
  8. Open source
  9. Learn Gleam

Socials

  1. GitHub
  2. X

Legal

  1. Privacy Policy
  2. Terms of Service