Questions

Rust questions

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

Store Closures in Structs in Rust: Generics, FnMut, and Trait Objects

Learn how to store Rust closures in structs using generic FnMut bounds, trait objects, lifetimes, and function pointers with practical examples.

rustclosures

Switch Between Rust Toolchains with rustup

Learn how to switch Rust toolchains with rustup defaults, directory overrides, rust-toolchain files, and one-command selections.

rustrustup

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

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.

rustmodule

Understanding dyn Trait Objects in Rust

Learn what dyn means in Rust types, how trait objects work, and when to use &dyn Trait or Box<dyn Trait> for dynamic dispatch.

rustsyntax

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.

rustreferencemove-semanticsborrow-checker

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.

rustmodulerust-macros

What Are Non-Lexical Lifetimes in Rust?

Learn what non-lexical lifetimes are in Rust, how they improve borrowing, and why the borrow checker became more flexible.

rustterminologylifetimelifetime-scoping

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.

rustpointers

What Rust Uses Instead of a Garbage Collector

Learn how Rust frees memory without a garbage collector using ownership, scope, and Drop, and how this differs from typical GC systems.

rustmemorymemory-managementgarbage-collection

What `let fields = fields;` Does in Rust

Learn what `let x = x;` means in Rust, how shadowing works, and why developers use `let fields = fields;` in real Rust code.

rust

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.

rustclosures

When to Use #[inline], #[inline(always)], and #[inline(never)] in Rust

Learn when to use Rust inline attributes, what they actually mean, and when #[inline], #[inline(always)], or #[inline(never)] help or hurt.

rustinlinellvm-codegen

Why Capitalizing the First Letter of a String Is Different in Rust

Learn why Rust string capitalization is tricky, why &str cannot be indexed, and the simplest safe ways to uppercase the first letter.

ruststringuppercase

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 You Can't Index a String in Rust and How to Access Characters Safely

Learn why Rust strings cannot be indexed by number and how to access characters safely using chars, bytes, and iterators.

ruststringindexing

Page 8 of 9 - 162 questions