eval
Log in

Closures that Own Their Environment

10 points

Implement make_logger, which returns a closure that formats a message with a fixed prefix, as "{prefix}: {msg}". prefix is a String passed by value into make_logger — the returned closure must capture it by move so it is still valid on every call, long after make_logger itself has returned.

Required signature

pub fn make_logger(prefix: String) -> impl Fn(&str) -> String;

Visible tests

Your solution

Log in to submit a solution.