Skip to main content

19 docs tagged with "rust"

View all tags

Collections

Vec for dynamic arrays, String for owned UTF-8 text, and HashMap for key-value storage -- creating, accessing, iterating, and common patterns.

Concurrency

Spawning threads, move closures for threads, message passing with channels (mpsc), shared state with Arc and Mutex, the Send and Sync traits, and an introduction to async/await with tokio.

Control Flow

if/else as expressions, loop, while, for with ranges and iterators, break and continue with labels, early introduction to match, and returning values from blocks.

Deploy to a VPS with nginx

Building for release, cross-compilation, creating a systemd service, setting up nginx as a reverse proxy, HTTPS with Let's Encrypt, Docker multi-stage builds, and CI/CD with GitHub Actions.

Error Handling

panic! vs recoverable errors, Result in depth, the ? operator, unwrap and expect, custom error types, the From trait for error conversion, the thiserror crate, and when to panic vs return a Result.

Functions

Defining functions, parameters and return types, the difference between expressions and statements, implicit returns, the unit type, nested functions, diverging functions, and documentation comments.

Introduction & Environment Setup

What Rust is, why it exists, how it compares to other languages, installing the toolchain with rustup, writing your first program, understanding Cargo, setting up your editor, and reading compiler errors.

Iterators & Closures

Closure syntax, capturing variables, Fn/FnMut/FnOnce traits, the Iterator trait, iterator adaptors like map/filter/fold/collect, chaining, lazy evaluation, and the difference between iter, into_iter, and iter_mut.

Lifetimes

Why lifetimes exist, lifetime annotations in function signatures and structs, the three lifetime elision rules, the 'static lifetime, and common lifetime patterns and pitfalls.

Modules & Crates

Organizing code with mod, pub, and use, file-based module structure, re-exports, library vs binary crates, workspaces, Cargo.toml dependencies, crates.io, semantic versioning, and feature flags.

Ownership & Borrowing

The stack and the heap, ownership rules, move semantics, the Copy and Clone traits, references and borrowing, mutable references, dangling references, String vs &str, and slices.

Pattern Matching

match exhaustiveness, destructuring structs and enums, if let, while let, the matches! macro, match guards, the wildcard pattern, nested patterns, and matching on Option and Result.

Practice Projects

Eight hands-on project ideas -- from beginner to advanced -- to reinforce everything you learned in the Rust Beginners Guide.

Project: CLI Task Manager

Build a complete CLI application with clap for argument parsing, serde for JSON serialization, file-based storage, proper error handling, and a modular project structure.

REST API with Actix Web

Building a REST API with Actix Web: project setup, routes, handlers, extractors, JSON with serde, application state, middleware, CORS, and connecting to SQLite.

Structs & Enums

Defining structs, field init shorthand, tuple structs, unit structs, impl blocks, methods, associated functions, enums, enum variants with data, Option, and Result.

Testing

Unit tests with #[test], the cfg(test) module, assert macros, testing panics, integration tests in the tests/ directory, doc tests, cargo test options, and test organization.

Traits & Generics

Defining traits, implementing traits for types, default methods, generic functions and structs, trait bounds, where clauses, standard library traits, derive macros, and trait objects.

Variables & Types

Declaring variables with let, understanding immutability by default, the mut keyword, shadowing, scalar types, compound types, type inference, type annotations, constants, and numeric overflow.