Rust Interview Questions
Ownership & borrowing, lifetimes, the borrow checker, traits, Option/Result, pattern matching, smart pointers, fearless concurrency and zero-cost abstractions.
61 questions
Popular Searches
1. What is Rust and what problems does it solve compared to C++?
easyLanguage Fundamentals 6 mins2. What is ownership in Rust and what are its three rules?
mediumOwnership 6 mins3. What is borrowing in Rust and how do references work?
mediumBorrowing 6 mins4. What is the difference between a mutable and an immutable reference in Rust?
mediumOwnership & Borrowing 7 mins5. What are lifetimes in Rust and why does the borrow checker need them?
hardOwnership & Borrowing 8 mins6. What is the difference between move, copy, and clone semantics in Rust?
mediumOwnership & Borrowing 7 mins7. What is the difference between String and &str in Rust?
easyOwnership & Types 6 mins8. What is the difference between a Vec and an array in Rust?
easyCollections 6 mins9. What are traits in Rust and how do they compare to interfaces?
mediumTraits & Generics 7 mins10. What is the difference between a struct and an enum in Rust?
easyTypes 6 mins11. How does Rust handle null with the Option type?
mediumError Handling 7 mins12. How does Rust handle errors with the Result type and the ? operator?
mediumError Handling 7 mins13. What is pattern matching in Rust and how does the match expression work?
mediumLanguage Fundamentals 7 mins14. What is the difference between Box, Rc, and Arc in Rust?
mediumSmart Pointers 8 mins15. What is interior mutability in Rust and how do Cell and RefCell provide it?
hardOwnership and Borrowing 8 mins16. What are closures in Rust and how do Fn, FnMut, and FnOnce differ?
mediumClosures 7 mins17. What are iterators in Rust and how does lazy evaluation work?
mediumIterators 7 mins18. What is the difference between fearless concurrency and data races in Rust?
hardConcurrency 8 mins19. What are the Send and Sync traits in Rust and what do they guarantee?
hardConcurrency 8 mins20. What is the difference between static and dynamic dispatch in Rust?
mediumTraits 7 mins21. What are generics in Rust and how do trait bounds constrain them?
mediumGenerics 7 mins22. What is a macro in Rust and how do declarative and procedural macros differ?
mediumMetaprogramming 7 mins23. What is the difference between panic! and returning a Result in Rust?
mediumError Handling 7 mins24. What is the newtype pattern in Rust and when do you use it?
mediumType System 7 mins25. What is zero-cost abstraction in Rust and why does it matter?
mediumLanguage Design 6 mins26. How does Rust manage memory without a garbage collector?
mediumMemory Management 7 mins27. What is the difference between Copy and Clone traits in Rust?
easyTraits 6 mins28. What is a slice in Rust and how does it borrow from a collection?
mediumOwnership & Borrowing 6 mins29. What is async/await in Rust and how do futures work?
hardConcurrency 8 mins30. What are modules and crates in Rust and how does the module system work?
easyProject Structure 5 mins31. Why does Rust async need Pin and Unpin, and when do you have to care?
hardAsync & Concurrency 9 mins32. What does unsafe Rust actually allow, and what invariants must you uphold?
hardUnsafe & FFI 9 mins33. How does Drop work in Rust, what order do values drop in, and where does it bite you?
hardOwnership 9 mins34. What makes a trait object-safe in Rust, and how do you work around the rules?
hardTraits & Generics 9 mins35. How does Cargo feature unification work, and how do you debug a feature that mysteriously turns on?
hardCargo & Tooling 9 mins36. How do you debug a deadlock or a poisoned Mutex in a Rust service?
hardAsync & Concurrency 10 mins37. What happens if you block inside an async task, and how do you detect and fix it?
hardAsync & Concurrency 10 mins38. How do you expose a Rust library over a C FFI boundary safely?
hardUnsafe & FFI 10 mins39. How do you design error types for a Rust library versus an application?
mediumError Handling 9 mins40. How do you profile and optimise a slow Rust program without guessing?
hardPerformance 10 mins41. What does a serious Rust testing strategy include beyond #[test] unit tests?
mediumTesting 10 mins42. What are higher-ranked trait bounds and variance in Rust, and when do they show up in errors?
hardType System 10 mins43. What are Rust's lifetime elision rules, and when must you write lifetimes explicitly?
mediumOwnership & Lifetimes 9 mins44. Why does RefCell panic with "already borrowed", and how do you design around it?
mediumInterior Mutability 9 mins45. When should you use Cow in Rust, and what does it actually save?
mediumPerformance & Types 9 mins46. How do you choose between Arc<Mutex<T>>, RwLock and channels for shared state in Rust?
hardConcurrency 11 mins47. What is the orphan rule in Rust, and how do you implement a foreign trait for a foreign type?
mediumTraits & Type System 9 mins48. How does monomorphisation affect Rust compile times and binary size, and when do you use dyn instead?
hardGenerics & Codegen 11 mins49. When do you use thiserror versus anyhow in Rust, and how do you add context to errors?
mediumError Handling 10 mins50. What is cancellation safety in Rust async, and how does select! lose data?
hardAsync & Concurrency 11 mins51. Why does tokio::spawn require Send + 'static, and how do you satisfy it without cloning everything?
hardAsync & Concurrency 10 mins52. How do you return a future from a trait method in Rust, and what are the trade-offs?
hardAsync & Traits 11 mins53. What counts as undefined behaviour in Rust, and how do you detect it in unsafe code?
hardUnsafe Rust 11 mins54. Are Rust iterator chains as fast as hand-written loops, and when are they not?
hardPerformance 11 mins55. How do Deref coercion, AsRef and Borrow differ, and which should an API accept?
mediumTraits & API Design 10 mins56. Why are Rust build times slow, and what actually improves them?
mediumBuild & Tooling 10 mins57. What are const generics and const fn in Rust, and where do they genuinely help?
mediumGenerics & Type System 10 mins58. How do atomics and memory ordering work in Rust, and when is Relaxed enough?
hardConcurrency 11 mins59. Why do you need mem::swap, mem::take and mem::replace in Rust?
mediumOwnership & Memory 9 mins60. What is PhantomData used for in Rust, and what does it change about a type?
hardType System 10 mins61. When should a Rust trait use an associated type instead of a generic parameter?
mediumTraits & Type System 9 mins