Why is this an issue?

Using closures when a function pointer can be used instead can negatively impact readability and maintainability of the code. Closures can obscure the intent of the code, making it harder for other developers to understand what the code is doing at a glance. Function pointers, on the other hand, are more explicit and can make the code more concise and easier to read.

How to fix it

Replace closures with function pointers when the closure simply calls a function. This makes the code more readable and easier to understand.

Code examples

Noncompliant code example

let result = Some('a').map(|s| s.to_uppercase());

Compliant solution

let result = Some('a').map(char::to_uppercase);

Resources

Documentation