Rust closure capture and Fn traits

F-FNTRAIT-V4-3hard

Call the badge callback every line

The registration batch first welcomes every supplied visitor and reports the batch count. Its payment pass prints a running admission total after every amount, then reconciles that total with the caller’s final report. Its badge pass reuses one callback for every name; badge text must remain available for the next call instead of being consumed by the first visitor.

What needs to change

Repair the callback in main so it can run once for every line.

Reproduce

  1. The starter does not compile; read the diagnostic before changing the code.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

The file contains its use declaration, read_rows, for_each_row and main. for_each_row takes an FnMut callback and is correct.

Input: one visitor’s name per line.

Supplied batches contain at most 1,000 single-word names. Rows are well formed; input validation is outside this task.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in