70 %
Chris Biscardi

Learning Rustlang

Coming from other languages, what should the path laid out be for people new to Rust? This list assumes you're coming from a language like JavaScript.

This list is the list for language constructs and the std library. There are other paths for building cli tools, serverless functions, or wasm.

Intro to Rust

  1. What is Rust useful for and why the fuck should I learn it?
  2. Installing Rust with Rustup
  3. Hello World! Rust is a statically typed, compiled language with high-level tools (println! macro)
  4. Mutable and Immutable variable declaration with let, type inference, and snake_case.

Data Types

  1. Primitive types: (booleans, strings, and characters)
  2. Overview of numbers: integers, floats, and i/usizes. integer literals.
  3. Compound types: tuples and structs

Functions

  1. functions, arguments, and return values
  2. Expressions vs statements
  3. Unit type and unit value
  4. Block expressions

Comments

  • // comments
  • /// doc comments
  • Markdown

Control Flow

  1. if and else expressions
  2. if-let
  3. loop, while, break, and for
  4. if-let and while-let

Structs and Enums

  1. Classic, Tuple, and Unit structs
  2. Shorthand names (Thing { name })
  3. Update syntax (..thing)
  4. Defaults with the Default trait

Iterators

  1. Why Iterators?
  2. iterators and for loops
  3. Ranges

Ownership

  1. What and Why Ownership?
  2. All values have a single variable owner
  3. When the owner goes out of scope, the value will be dropped
  4. Scope
  5. Slices
  6. String vs &str
  7. Moving owners between variables
  8. Moving into and out of functions
  9. Copy, Drop, Clone

References and Borrowing

  1. References vs Ownership
  2. Immutable and mutable references
  3. What's a data race and why would you want to avoid one?
  4. Dereferencing

Modules

  1. What are modules?
  2. Organizing a project with modules
  3. Using functions from another module

Cargo

  1. Using 3rd party packages

Lifetimes

Generalizing library functions

  1. fn thing(s: String) vs fn thing(s: &str)

HashMaps and BTreeMaps

Entry API

  • What is the Entry API?
  • .entry
  • .or_insert()
  • .or_insert_with()
  • .or_insert_with_key()
  • .key
  • .and_modify
  • .or_default
  • [nightly] .insert