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.

rustvector

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.

rust

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.

ruststring

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.

rustmoduleprogram-entry-pointrust-cargo

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.

rustiterator

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().

ruststringiterator

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.

rustenumsiteration

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.

rustfor-loopiterator

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.

ruststring

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.

rust

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.

rusthttp

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.

ruststringmatch

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.

rust

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.

rustprintln

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.

rusttypes

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.

rust

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.

rust

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.

rustdefault-value

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.

rustsorting

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.

rustmodule

Page 3 of 6 - 112 questions