Questions

Rust questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Rust Copy vs Clone: What’s the Difference?

Learn the difference between Copy and Clone in Rust, when each is used, and how ownership affects assignment and duplication.

rust

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.

ruststringsyntax

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.

rustrust-cargo

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.

ruststring

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.

rustiterator

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.

rustrust-cargo

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.

rustreferencestatic-analysislifetime

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.

rust

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.

rustreferencelifetimeborrow-checker

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.

rustrust-cargo

Why Rust May Not Optimize Non-Aliasing Mutable References Yet

Learn why Rust mutable references imply no aliasing, why LLVM may still avoid some optimizations, and how this relates to UB and codegen.

rustreferencecompiler-optimizationllvm-codegen

Why `println!` Doesn’t Show in Rust Unit Tests

Learn why `println!` output is hidden in Rust unit tests, how test output capture works, and how to display debug prints when needed.

rusttestingprintln

Page 2 of 2 - 32 questions