Rust theorytheory 0/50 · 0%
Abstraction · medium

26. Closures

Fn, FnMut and FnOnce.

Closures capture their environment by reference, mutable reference or value, inferring the least restrictive of Fn, FnMut and FnOnce. `move` forces capture by value, which is required when spawning threads or returning closures from functions.

Check your understanding

  1. 1. Which trait consumes captured values?

  2. 2. What does `move` do?