Questions
Rust questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Get a Slice of a Vec<T> in Rust
Learn how to get a slice from a Vec<T> in Rust using range syntax, borrowing rules, and safe examples for beginners.
How to Get the Current Time in Milliseconds in JavaScript
Learn how to get the current time in milliseconds in JavaScript, including Date.now(), new Date().getTime(), and common mistakes.
How to Get the First Character of a String in Rust
Learn how to get the first character from a Rust string safely using chars(), bytes, and string slicing basics.
How to Import Modules from Another File in Rust Cargo Projects
Learn how to split Rust code into multiple files and import modules correctly in a Cargo project using mod and module paths.
How to Iterate Over a Range with a Custom Step in Rust
Learn how to loop over ranges with custom step sizes in Rust using iterators like step_by, with examples, pitfalls, and practice.
How to Iterate Over a String by Character in Rust
Learn how to iterate through strings in Rust, when to use chars(), and better ways to search text with contains() and find().
How to Iterate Through Enum Values in Rust
Learn how to iterate over enum values in Rust, why enums do not auto-list variants, and practical ways to loop through them safely.
How to Iterate a Vec with Its Index in Rust
Learn how to iterate over a Vec with index positions in Rust using iter().enumerate(), with examples, pitfalls, and real use cases.
How to Join a Vec<String> into One String in Rust
Learn how to join a Vec<String> into a single String in Rust using join(), with examples, pitfalls, and practical patterns.
How to List Files in a Directory in Rust
Learn how to list files in a directory in Rust using std::fs::read_dir, with examples, error handling, and common beginner mistakes.
How to Make an HTTP Request in Rust
Learn how to make HTTP requests in Rust, check status codes, and safely encode query parameters with practical examples.
How to Match a String in Rust: String vs &str in match Expressions
Learn how to match String values in Rust using &str, as_str(), and pattern matching with clear examples and common mistakes.
How to Pass a Function as a Parameter in Rust
Learn how to pass functions as parameters in Rust using function pointers, generics, and closures with simple examples.
How to Print a Vec in Rust: Display vs Debug
Learn why Vec<T> cannot be printed with {} in Rust and how to use Debug formatting, pretty printing, and custom Display output.
How to Print the Type of a Variable in Rust
Learn how to inspect and print a variable's type in Rust using std::any::type_name, with examples, caveats, and beginner-friendly guidance.
How to Return an Iterator in Rust
Learn the correct way to return iterators and trait types in Rust, including impl Iterator, trait objects, lifetimes, and common mistakes.
How to Round a Floating-Point Number to a Specific Number of Decimal Places in Rust
Learn how to round f64 values to a chosen number of decimal places in Rust with clear examples, pitfalls, and practical patterns.
How to Set Default Values for Structs in Rust
Learn concise ways to initialize Rust structs with default values using constructors, the Default trait, and struct update syntax.
How to Sort a Vector in Rust
Learn the recommended way to sort a vector in Rust using sort, sort_unstable, and custom comparators with clear examples.
How to Split a Rust Module Across Multiple Files
Learn how to organize a Rust module across several files using mod, pub mod, and re-exports with practical examples and common mistakes.