Questions

Rust questions

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

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

How to Build Multiple Binaries with Cargo in Rust

Learn how to build multiple binaries with Cargo in Rust, including daemon/client layouts, shared libraries, and Cargo.toml setup.

rustrust-cargo

How to Check Debug vs Release Builds in Rust with cfg and cfg!

Learn how to detect debug and release builds in Rust using #[cfg] and cfg! with clear examples, common mistakes, and practical usage.

rustdebuggingrust-cargopreprocessor

How to Check Whether a Path Exists in Rust

Learn how to check whether a file or path exists in Rust using Path::exists, metadata, and Result handling with clear examples.

rust

How to Concatenate Strings in Python: str and String-Like Values

Learn how to concatenate strings in Python, including str values and string-like objects, with examples, mistakes, and best practices.

ruststringstring-concatenation

How to Concatenate Vectors in Rust

Learn how to concatenate vectors in Rust using append, extend, iterators, and ownership rules with clear examples and common pitfalls.

rustvectorconcatenation

How to Convert String to &'static str in Rust

Learn how String, &str, and &'static str differ in Rust, when conversion is possible, and safe ways to create static string slices.

rust

How to Convert Vec<char> to String in Rust

Learn how to convert a Vec<char> into a String in Rust, print it correctly, and understand why collect() works.

ruststring

How to Convert Vec<u8> or &[u8] to String in Rust

Learn how to convert Vec<u8> or &[u8] to String in Rust, handle UTF-8 safely, and print TCP response buffers correctly.

rust

How to Convert a Slice to a Fixed-Size Array in Rust

Learn how to convert a Rust slice into a fixed-size array safely using array patterns, try_into, and borrowing rules.

rustarrays

How to Convert a String to an Integer in Rust

Learn how to convert String and &str to integers in Rust using parse, borrowing, and error handling with clear examples.

rust

How to Create Enums With Constant Values in Rust

Learn how Rust enums work with associated data, constants, discriminants, and practical patterns for fixed values in enum variants.

rust

How to Create a Global Mutable Singleton in Rust

Learn safe ways to build a global mutable singleton in Rust, including statics, lazy initialization, Mutex, and OnceLock patterns.

rust

How to Create a HashMap Literal in Rust

Learn how to create HashMap values in Rust, including nested maps, collect(), macros, and practical patterns for beginners.

rusthashmap

How to Create a Zero-Filled Vector of Dynamic Size in Rust

Learn idiomatic ways to create a zero-filled Vec in Rust when the size is only known at runtime, with examples and common mistakes.

rust

How to Disable Dead Code Warnings at the Crate Level in Rust

Learn how crate-level attributes work in Rust and how to disable dead_code warnings across an entire crate safely and clearly.

rustcompiler-warningsdead-code

How to Do Exponentiation in Rust

Learn how to raise numbers to a power in Rust, why `^` is not exponentiation, and how to use `pow` correctly with integers and floats.

rustoperatorsexponentiation

How to Escape Curly Braces in Rust Format Strings

Learn how to escape curly braces in Rust format strings using doubled braces like {{ and }} with clear examples and common mistakes.

ruststring-formatting

How to Find the Index of an Element in a Vec, Array, or Slice in Rust

Learn how to find an element index in a Rust Vec, array, or slice using position(), enumerate(), and safe usize handling.

rustiterator

How to Fix a "Use of Moved Value" Error in Rust with Borrowing

Learn why Rust shows "use of moved value" for Vec and how borrowing with references fixes it safely and idiomatically.

rust

Page 2 of 6 - 112 questions