Questions
Rust questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Accessing Cargo Package Metadata in Rust
Learn how to read Cargo package metadata like version, name, and authors in Rust using compile-time environment macros.
Associated Types vs Generic Type Parameters in Rust: When to Use Each
Learn when to use associated types vs generic parameters in Rust traits, with clear rules, examples, and practical API design advice.
Can a Struct Extend Another Struct in Rust? Composition vs Inheritance
Learn how Rust handles struct reuse without inheritance, using composition, traits, and wrapper structs with practical examples.
Convert Option<String> to Option<&str> in Rust
Learn the idiomatic Rust way to convert Option<String> into Option<&str> using as_deref, as_ref, and unwrap_or without extra allocation.
Convert a Vec<T> to a Fixed-Size Array in Rust
Learn how to convert a Vec<T> into a fixed-size array in Rust, when it works, what can fail, and the safest patterns to use.
Convert an Integer to a String in Rust
Learn the current Rust way to convert integers to strings, why `to_str()` no longer works, and when to use `to_string()` or `format!`.
Converting Between String, &str, Vec<u8>, and &[u8] in Rust
Learn idiomatic Rust conversions between String, &str, Vec<u8>, and &[u8], including UTF-8 rules, borrowing, ownership, and examples.
Converting Option to Result in Rust Without a Macro
Learn how to convert Option into Result in Rust using ok_or and ok_or_else, with examples, common mistakes, and practical patterns.
Counting Characters in Rust Strings: bytes vs chars
Learn why Rust String::len returns bytes, how to count chars with .chars().count(), and what to use for user-visible text length.
Cross-Compiling Rust from Linux to Windows
Learn how to cross-compile a Rust program from Linux to Windows, including targets, standard library setup, linkers, and common errors.
Default Function Arguments in Rust: What to Use Instead
Learn how Rust handles default function arguments, why they are not supported, and practical patterns to achieve similar behavior.
Difference Between `self` and `Self` in Rust
Learn the difference between `self` and `Self` in Rust, when to use each one, and how they appear in methods, impl blocks, and traits.
Does `cargo install` Have an Update Command in Rust?
Learn how to update globally installed Cargo packages in Rust, what `cargo install` does, and the common ways developers reinstall tools safely.
Fixing Rust "link.exe not found" on Windows: Understanding the MSVC Linker
Learn why Rust on Windows fails with "link.exe not found" and how MSVC toolchains, linkers, and Visual C++ build tools work.
Fixing Rust "linker 'cc' not found" on Debian in WSL
Learn why Rust shows "linker 'cc' not found" on Debian in WSL and how to fix it by installing the required C build tools.
Fixing “No Default Toolchain Configured” in Rust After Installing rustup
Learn why rustup shows “no default toolchain configured” and how to fix cargo and rustc by setting a default Rust toolchain.
Global Variables in Rust: statics, shared state, and better alternatives
Learn whether Rust supports global variables, how `static` works, why `static mut` is risky, and safer patterns for shared state.
Handling Errors While Mapping Iterators in Rust
Learn how to stop iterator processing and return errors in Rust using collect, Result, and iterator patterns.
How Rust i128 Works on 64-Bit Systems
Learn how Rust's i128 and u128 work on 64-bit CPUs, including memory layout, arithmetic, compiler support, and practical examples.
How to Access Command Line Arguments in Rust
Learn how to read command line arguments in Rust using std::env::args, with examples, common mistakes, and practical patterns.
Page 1 of 6 - 112 questions