quest

Sign in to start training

quest keeps your progress, streaks, and scores tied to your account — so you can pick up on any device.

Synced everywhere. Progress follows you across laptop and phone.
Streaks & stats. See your daily run and every score over time.
Your profile. A name and avatar for the work you do here.

We only use Google to sign you in and sync progress. No posting, no contacts — ever.

Core Intermediate

09  Closures

A closure is a small anonymous function that can capture variables from its surroundings. Return one from a function, then accept one as an argument -- the two shapes iterator chains are built from.

Step 1 / 2

Make make_adder return a closure that adds n to its argument.

Hints
  • Closure syntax: |x| x + n -- arguments between pipes, body after.
  • The closure outlives make_adder, so it must own n: write move |x| x + n.
09_closures.rs
Reset to starterCompiled in a sandbox; hidden checks must pass.
Reveal solution
fn make_adder(n: i32) -> impl Fn(i32) -> i32 {
    move |x| x + n
}