Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

50 Rust Oral Questions

This chapter is for spoken recall. Each answer is intentionally short so it can be repeated out loud.

Core Language

1. What is ownership in Rust?

Ownership is Rust's way of assigning lifetime responsibility to a value. A value has one controlling owner at a time, and that owner determines when the value is dropped.

2. What is borrowing in Rust?

Borrowing is temporary access to a value without taking ownership. It controls how references may access a value during its lifetime.

3. What is the cleanest distinction between ownership and borrowing?

Ownership manages lifetime. Borrowing manages access.

4. What is the difference between &T and &mut T?

&T is shared read-only access. &mut T is exclusive mutable access.

5. Why does Rust allow many readers or one writer?

That rule prevents conflicting access patterns. It helps Rust preserve correctness without a garbage collector.

6. What is a move?

A move transfers ownership from one binding to another. It does not destroy the value; it changes who is responsible for it.

7. What is a drop?

Drop is destruction of the value. It happens when the current owner goes out of scope, unless ownership has moved elsewhere.

8. What is the difference between a move and a drop?

A move changes ownership. A drop destroys the value.

9. What is a binding?

A binding is a name associated with a value, usually introduced by let, a pattern, or a function parameter.

10. What is the difference between a variable and a binding?

Variable is the common informal term. Binding is the more precise Rust term.

Types and Memory

11. What is the difference between a type and a value?

A type is a description of shape and rules. A value is the actual runtime thing that occupies memory.

12. What actually takes memory at runtime?

Values take memory. Types describe values.

13. What does it mean for a value to be of type T?

It means the value has the structure and behavior described by the type T.

14. Why is Rust said to have a strong type system?

Rust makes important distinctions explicit and rejects many invalid combinations at compile time. It does not casually blur meanings together.

15. Why do you like Rust's type system?

Because it is not only restrictive, it is clear. It makes states and distinctions explicit instead of hiding them in convention.

16. What is String vs &str?

String is an owned growable string buffer. &str is a borrowed string slice.

17. What is stack vs heap intuition in Rust?

Fixed-size values are often stored directly in stack frames. Types like String and Vec store metadata directly, while their dynamic contents live on the heap.

18. What is shadowing?

Shadowing creates a new binding with the same name as an earlier one. It is a binding rule, not an ownership rule.

19. Why would you use shadowing?

To transform a value cleanly, change type, or create a new stage of a value without inventing new names.

20. What is the difference between let mut x and let x = x + 1?

let mut x allows mutating the same binding. let x = x + 1 creates a new shadowing binding.

Enums, Patterns, and Matching

21. Why is Option important in Rust?

It makes absence explicit in the type system instead of relying on null-like ambiguity.

22. Why is Result important in Rust?

It makes success and failure explicit as part of the program structure.

23. What does exhaustiveness in match guarantee?

It guarantees that all possible cases of the matched value are handled.

24. Why does Some(x) create a new binding?

Because patterns in Rust can destructure values and bind parts of them to names.

25. Why was x => ... in a match arm unreachable for later arms?

Because a bare identifier in a pattern is a catch-all binding. It matches any remaining value.

26. Can match return a value?

Yes. match is an expression, so each arm can produce a value and the whole match evaluates to one value.

27. Why must all match arms have compatible types?

Because the whole match is one expression, and every expression in Rust must have a coherent resulting type.

28. What does .. mean in a pattern?

It means ignore the rest of the fields or elements.

29. What is the struct catch-all pattern?

For a struct type, it is usually StructName { .. }.

30. What is the usual match-arm convention?

Most specific patterns first, most general catch-all pattern last.

Traits, Generics, and Abstraction

31. What is a trait in Rust?

A trait defines shared behavior that different types can implement.

32. What does T: Display mean?

It means the function is generic over some concrete type T, and T must implement Display.

33. Why isn't Display itself used directly as a parameter type?

Because Display is a trait, not a concrete type. You need a generic bound, impl Trait, or a trait object.

34. What is the point of Display in fn print_twice<T: Display>(value: T)?

The repetition comes from calling println! twice. The Display bound is what makes the function generic over printable types.

35. What is impl Trait?

It means some concrete type implementing that trait, without naming the type parameter explicitly.

36. What is dyn Trait?

It is a trait object used for dynamic dispatch behind a reference, box, or pointer.

37. What is the difference between impl Trait and dyn Trait?

impl Trait uses static dispatch and a concrete hidden type. dyn Trait uses dynamic dispatch through a trait object.

38. What is a generic type parameter?

It is a placeholder for a family of concrete types, optionally constrained by trait bounds.

39. Why are generics useful?

They let you write reusable code without giving up type safety.

40. What is a lifetime in Rust?

A lifetime describes how long references are valid relative to the values they point to.

Concurrency, Async, and Unsafe

41. What do Send and Sync mean?

Send means a value can move across threads. Sync means a shared reference can be used across threads.

42. What is Arc<Mutex<T>> modeling?

Shared ownership across threads plus synchronized mutable access to the inner value.

43. Why does async Rust interest you?

Because it reveals progress and scheduling issues that the type system alone does not solve. It is where more responsibility shifts back to the engineer.

44. What does an async fn return?

It returns a future.

45. Why are futures described as state machines?

Because the compiler transforms async code into a state machine that can pause and resume across await points.

46. Why is blocking inside async dangerous?

Because it can block a runtime worker thread and starve other tasks of polling capacity.

47. When should you use spawn_blocking?

When work is synchronous or blocking and should be isolated from the async worker pool.

48. What does unsafe mean?

It means the compiler is trusting the engineer to uphold extra invariants that it cannot verify automatically.

49. Why does unsafe Rust interest you?

Because it makes the invariant-carrying boundary explicit. It shows exactly where language guarantees stop and engineering responsibility begins.

50. What is your compact Rust worldview?

Rust uses types, ownership, and explicit state modeling to make important distinctions visible and invalid states harder to represent. The parts that interest me most are the boundaries where more responsibility shifts back to the engineer, especially async and unsafe Rust.