Questions
Rust questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Rust HashMap Entry API: Lookup or Insert Efficiently
Learn how to lookup or insert values in a Rust HashMap efficiently using the Entry API, with examples and common mistakes.
Rust Lifetimes Explained: What 'a, 'r, and 'static Mean
Learn what Rust lifetimes like 'a, 'r, and 'static mean, why the apostrophe matters, and how lifetimes work with references.
Rust Multiline String Literals: Syntax, Raw Strings, and Line Breaks
Learn Rust multiline string literal syntax, including normal and raw strings, line breaks, escapes, and common mistakes beginners make.
Rust Package with Both a Library and a Binary
Learn how to structure a Rust package with both a reusable library and an executable using Cargo.toml, src/lib.rs, and src/main.rs.
Rust String vs str: Differences, Uses, and When to Choose Each
Learn the difference between Rust `String` and `str`, when to use each, and how owned and borrowed string types work in practice.
Rust Traits vs Haskell Typeclasses: Key Differences Explained
Learn the difference between Rust traits and Haskell typeclasses with examples, comparisons, and practical usage patterns.
Rust `iter()` vs `into_iter()`: Understanding Borrowed and Owned Iteration
Learn the difference between Rust `iter()` and `into_iter()`, including ownership, borrowing, arrays, vectors, and practical examples.
Rust `use` vs `extern crate`: What’s the Difference?
Learn the difference between Rust `use` and `extern crate`, why both existed, when to use them, and how modern Rust imports crates.
Rust unwrap() Explained: Using Result and Option Safely
Learn what unwrap() does in Rust, how it works with Result and Option, when to use it, and safer alternatives for error handling.
Safe and Idiomatic Numeric Type Conversion in Rust
Learn safe, idiomatic numeric conversions in Rust using casts, TryFrom, From, and pointer-sized types like usize and isize.
Understanding Cargo Registry Locking in Rust: Why `cargo build` Waits for a File Lock
Learn why Rust Cargo shows "Blocking waiting for file lock on the registry index" on macOS and how to diagnose and fix it safely.
Understanding Rust Modules with main.rs and lib.rs
Learn how Rust module lookup works with main.rs and lib.rs, why crate::foo fails, and how to organize binary and library crates correctly.
Understanding “Cannot Move Out of Borrowed Content” in Rust
Learn why Rust shows “cannot move out of borrowed content”, how ownership and borrowing interact, and how to fix it safely.
Using macro_rules! Across Module Files in Rust
Learn how to use macro_rules! macros across module files in Rust, including #[macro_use], #[macro_export], scope rules, and practical examples.
What Is a Fat Pointer in Rust? Slices, Trait Objects, and Why They Are Larger
Learn what fat pointers are in Rust, why they are larger than normal pointers, and how slices and trait objects use them.
When Rust Closures Implement Fn, FnMut, and FnOnce
Learn when Rust closures implement Fn, FnMut, and FnOnce, how capture behavior affects each trait, and how to choose the right bound.
Why Explicit Lifetimes Are Needed in Rust
Learn why Rust needs explicit lifetimes, when inference is enough, and when lifetime annotations are required for safe references.
Why Rust Avoids &String, &Vec, and &Box in Function Arguments
Learn why Rust functions usually take &str, slices, or plain references instead of &String, &Vec, and &Box, with examples and best practices.
Why Rust Cannot Store a Value and a Reference to It in the Same Struct
Learn why self-referential structs fail in Rust, what lifetime errors mean, and practical ways to model owned data safely.
Why Rust Executables Are So Large: Understanding Binary Size in Rust
Learn why Rust binaries can seem large, what gets included in a build, and how debug, release, stripping, and panic settings affect size.