Skip to main content
InterviewHubPRO
Section Overview
Q20

Question 20 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

40%
Rust Systems & Tokio (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What are Closures in Rust and the three Closure Traits (`Fn`, `FnMut`, `FnOnce`)?

senior LevelMost AskedClosures & ScopeSystem Design

In Simple Words: Anonymous functions that can capture their enclosing environment:

  1. FnOnce: Consumes captured variables by value (ownership moved). Can only be called once.
  2. FnMut: Mutates captured variables. Can be called multiple times.
  3. Fn: Borrows captured variables immutably. Pure read-only; can be called concurrently.