Questions

Rust questions

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

Rust Modulus vs Remainder: How to Get True Modulo with Negative Numbers

Learn the difference between remainder and modulus in Rust, why % is not true modulo, and how to get positive modulo results safely.

rustmodulo

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 Raw String Literals: What r#"..."# Means and How Interpolation Works

Learn what Rust raw string literals like r#"..."# do, why they help with JSON, and how to insert variable values correctly in Rust.

ruststringsyntaxstring-literals

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 Traits vs Haskell Typeclasses: Key Differences Explained

Learn the difference between Rust traits and Haskell typeclasses with examples, comparisons, and practical usage patterns.

rusthaskelltraits

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

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

Rust `usize` vs `u32`: What’s the Difference and When to Use Each

Learn the difference between Rust `usize` and `u32`, when each should be used, and why pointer-sized integers matter in real programs.

rust

Rust clone() vs to_owned(): What’s the Difference?

Learn the difference between clone() and to_owned() in Rust, including ownership, borrowed vs owned data, and practical string examples.

rust

Rust mut Before a Variable Name vs After the Colon Explained

Learn the difference between `mut foo: T` and `foo: &mut T` in Rust, with examples of mutable bindings versus mutable references.

rustvariablessyntaxreference

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.

rusterror-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.

rustcastingnumbers

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 “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

Page 5 of 6 - 112 questions