Rust 101 — Fundamentals
Welcome to Rust 101
Section titled “Welcome to Rust 101”You already know TypeScript. You understand types, functions, and how to build real software. This module uses that knowledge as a bridge — every concept is introduced by comparing it to something you already know, then showing the Rust way.
What you will learn
Section titled “What you will learn”This module covers the core building blocks of Rust that map to everyday TypeScript patterns:
- Variables —
let,let mut,const, shadowing, and type inference - Functions — typed parameters, return types, and expression-oriented syntax
- Control flow —
ifas an expression,match,loop,while,for - Structs — the Rust alternative to classes and interfaces
- Enums — algebraic data types and exhaustive pattern matching
- Collections —
Vec,HashMap, arrays, tuples, slices - Option and Result — replacing
null/undefinedandtry/catch - Modules and crates — the Rust equivalent of ESM and npm
By the end you will have the vocabulary to read and write real Rust programs.
Your first side-by-side
Section titled “Your first side-by-side”Both programs greet the user. The structure is similar, but Rust is compiled, statically typed, and has no runtime — println! is a macro that resolves format strings at compile time.
const name = "TypeScript developer";console.log(`Hello, ${name}! Welcome to Rust.`);fn main() { let name = "TypeScript developer"; println!("Hello, {}! Welcome to Rust.", name);}Try it
Section titled “Try it”Run the Rust snippet above directly in your browser.
fn main() { let name = "TypeScript developer"; println!("Hello, {}! Welcome to Rust.", name);}Compiling…