3 ms·
You can also replace the closure in the fold with Add::add, where Add is std::ops::Add: let total = (1..).map(|x| x * x).take(10).fold(0, Add::add); This is
by jonreem 12y ago
You can also replace the closure in the fold with Add::add, where Add is std::ops::Add:
let total = (1..).map(|x| x * x).take(10).fold(0, Add::add);
This is an application of UFCS, which allows you to call methods as regular functions.