Rust interview questions
Async Rust
Futures and polling,
async/.await, runtimes such as Tokio,Pin, cancellation, and blocking inside async code.15 questions
Rust Basics
Toolchain and Cargo,
letandmut, shadowing,constandstatic, scalar types, integer overflow, conversions, tuples and arrays — where every Rust interview starts.18 questions
Borrowing and References
&and&mut, the one-writer-or-many-readers rule, non-lexical lifetimes, dangling references, slices and&str.16 questions
Closures and Iterators
Closures and their capture modes,
move,Fn/FnMut/FnOnce, theIteratortrait, adapters and laziness.13 questions
Collections and Strings
Vecand its capacity,Stringvs&strand UTF-8,HashMapand the entry API,HashSet,BTreeMapandVecDeque.16 questions
Concurrency
Threads and
move, channels,MutexandArc,SendandSync, scoped threads, atomics and deadlocks.20 questions
Control Flow and Functions
ifas an expression,loopwith a value,while,forover ranges, labels, functions, and the line between expressions and statements.12 questions
Enums and Pattern Matching
Enums that carry data,
Option,matchand exhaustiveness,if letandlet else, and the pattern syntax.11 questions
Error Handling
panic!vsResult, the?operator,unwrapandexpect, custom error types,Fromconversions,Box<dyn Error>, thiserror and anyhow.14 questions
Generics and Traits
Generic functions and types, traits and default methods, bounds and
where,impl Trait, standard traits, monomorphization and coherence.15 questions
Lifetimes
Lifetime annotations, the elision rules, structs that hold references,
'static, and variance at the senior level.12 questions
Macros
macro_rules!and hygiene, procedural and derive macros, and when a macro is the right tool.6 questions
Modules, Crates and Cargo
Crates and modules, visibility,
usepaths, Cargo dependencies, features and workspaces, editions, clippy and rustfmt.13 questions
Ownership
Stack and heap, the three ownership rules, moves,
CopyandClone,Drop, and how ownership travels through function calls.17 questions
Memory and Performance
Zero-cost abstractions, memory layout and niche optimization, allocation, benchmarking and profiling.
9 questions
Smart Pointers
Box,DerefandDrop,Rc,RefCelland interior mutability,Weakand reference cycles,Cow.15 questions
Structs and Methods
Structs, tuple and unit structs,
implblocks, theselfreceiver forms, associated functions andderive.11 questions
Testing
#[test], the assert macros,#[should_panic], integration and doc tests, and how Rust code is mocked.7 questions
Trait Objects and Advanced Traits
dyn Traitand vtables, dyn compatibility, static vs dynamic dispatch, associated types, operator traits, the orphan rule and supertraits.8 questions
Unsafe Rust and FFI
What
unsafeunlocks, raw pointers, undefined behavior, calling C through FFI, and safe abstractions over unsafe code.12 questions