Questions

Rust questions

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

How to Split a String in Rust

Learn how to split strings in Rust using `split`, delimiters, patterns, and practical examples for parsing text safely.

rust

How to Test for Panics in Rust Unit Tests

Learn how to write Rust unit tests that verify a panic occurs using should_panic and catch_unwind, with examples and common mistakes.

rustunit-testing

How to Uninstall Rust Installed with rustup on Ubuntu

Learn how to uninstall Rust installed via rustup on Ubuntu, remove toolchains cleanly, and understand what rustup manages.

rustrustup

How to Update Cargo to the Latest Official Release in Rust

Learn how Cargo is updated in Rust, why Cargo and rustc versions can differ, and the correct way to get the latest stable release.

rustpackage-managersrust-cargo

How to Update Values in a Rust HashMap

Learn why Rust HashMap indexing is immutable and how to update values safely using get_mut, insert, and entry APIs.

rusthashmap

How to Use a Local Unpublished Crate in Rust

Learn how to use a local unpublished crate in Rust with Cargo path dependencies, Cargo.toml setup, and practical examples.

rustrust-crates

Idiomatic Callbacks in Rust: Fn, FnMut, FnOnce, and Box<dyn FnMut()>

Learn the idiomatic way to implement callbacks in Rust using Fn, FnMut, FnOnce, generics, and boxed trait objects.

rustcallback

Immutable Variables vs const in Rust: What’s the Difference?

Learn the difference between immutable variables and const in Rust, including scope, evaluation time, type rules, and practical examples.

rustconstantsimmutability

Interactive Debugging in Rust: Breakpoints, Stepping, and Inspecting Variables

Learn how interactive debugging works in Rust using breakpoints, stepping, and variable inspection with practical examples and debugger basics.

rustdebugging

Managing Object Lifetimes Safely in Rust Garbage Collector APIs

Learn how Rust lifetimes model heap-owned object validity and how to design safer garbage collector APIs with handles and borrowing.

rustgarbage-collectionallocationlifetime

Reading and Writing Files in Rust 1.x Without Panicking

Learn the idiomatic way to read and write files in Rust 1.x using Result, File, BufReader, and proper error handling.

rustfile-io

Returning Values vs References from Functions in Rust

Learn why Rust functions usually return owned values instead of references to local variables, with file handling examples using File and OpenOptions.

rustreferencelifetime

Reverse for Loops in Rust: Iterating from 100 Down to 1

Learn how to write reverse for loops in Rust, including descending ranges, rev(), inclusive ranges, and common pitfalls.

rustfor-loop

Run System Commands and Capture Output in Rust

Learn how to execute system commands in Rust and capture stdout, stderr, and exit status using std::process::Command.

rust

Rust ? Operator Explained: Error Propagation for Beginners

Learn what the `?` operator means in Rust, how it propagates errors, and when to use it with `Result` and `Option` values.

rustsyntax

Rust Array Loop Performance: Why Size Changes Can Affect Optimization

Learn why Rust array loop performance can change with size, and how compiler optimizations like unrolling and constant folding affect timing.

rustarraysperformancellvm-codegen

Rust Auto-Dereferencing Rules in Method Calls Explained

Learn Rust's auto-dereferencing and auto-borrowing rules for method calls, including Deref, receiver lookup order, and common edge cases.

rustreferencelanguage-lawyer

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

rusthashmaplookup

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

Page 4 of 6 - 112 questions