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

Implementing IntoIterator and Iterator for a Rust Struct

Learn how to implement Rust's IntoIterator for a simple struct, choose a concrete iterator type, and support owned and borrowed iteration.

rustiterator

Inspect Rust Macro Expansion with cargo expand and rustc

Learn how to inspect expanded Rust macro code with cargo expand and rustc, interpret macro error spans, and debug recursive macros effectively.

rustdebuggingrust-macrosrust-proc-macros

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

Mapping Over Vectors in Rust with Iterator map

Learn how to transform Rust vectors with Iterator::map and collect, why map is lazy, and why it belongs to iterators rather than Vec.

rust

Match Rust Enum Values with Integers Safely

Learn why Rust enums and integers cannot be matched directly, how to compare discriminants, and how to safely convert integers with TryFrom.

rust

Mutating Struct Fields in Rust Methods with &mut self

Learn how to mutate Rust struct fields from methods using &mut self, mutable bindings, borrowing rules, examples, and common mistakes.

rustmutable

Parameterized Tests in Rust: Data-Driven Test Cases

Learn how to create parameterized and data-driven tests in Rust using loops, test crates, and file-based inputs with useful failure output.

rustunit-testingtesting

Parse JSON Files in Rust with serde_json

Learn how to read a JSON file in Rust, deserialize it with serde_json, and safely access fields such as Age using typed structs.

rustjson

Quake Fast Inverse Square Root in Rust

Learn how to implement Quake's fast inverse square root in Rust safely with f32::to_bits and f32::from_bits.

rustfloating-pointsqrttype-punning

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

Remove an Element by Value from a Rust Vec<T>

Learn how to remove values from Rust Vec<T> using iter().position(), remove(), retain(), and swap_remove(), including complexity and examples.

rust

Page 5 of 9 - 162 questions