Questions

Rust questions

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

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.

rust

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

ruststringtype-conversioninteger

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.

ruststringtype-conversion

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.

rust

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.

ruststring

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.

rustlinuxwindowscross-compiling

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.

rustfunctionparametersarguments

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.

rust

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.

rustrust-cargo

Downcasting Trait Objects to Concrete Types in Rust

Learn why Rust cannot cast Box<dyn Trait> to Box<Concrete>, and safely recover references or ownership with Any downcasting.

rusttraits

Fix rust-analyzer Workspace Discovery in VS Code

Learn why rust-analyzer cannot discover a Rust Cargo workspace in VS Code and how to fix folder, manifest, toolchain, and Cargo issues.

rustvisual-studio-codevscode-extensionsrust-analyzer

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.

rustcompiler-errorsinstallationlinker-errors

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.

rustlinuxwindows

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.

rustrustup

Get an Owned Value from a Box in Rust

Learn how to move an owned value out of Box<T> in Rust, why *value is safe, and when Box::into_raw requires unsafe code.

rustunsafe

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.

rustglobal-variables

Handling Errors While Mapping Iterators in Rust

Learn how to stop iterator processing and return errors in Rust using collect, Result, and iterator patterns.

rustrust-result

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.

rustx86-64bigintint128

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.

rustcommand-line

How to Benchmark Programs in Rust

Learn how to measure execution time and benchmark Rust code using Instant, cargo bench, and practical benchmarking patterns.

rusttimebenchmarking

Page 2 of 9 - 162 questions