DEV Community

Discussion on: Higher-Order Functions in Rust

Collapse
 
deciduously profile image
Ben Lovy • Edited

Definitely, good catch - map was probably a bad choice of name. This example is not a pure functional style, but higher-order functions do not need to be pure. I thought that example was more interesting - if you do need a pure map I generally recommend using the standard library. I'd argue the above functions are still "functional programming", just not "pure functional programming". I don't know that I'd call it unsafe - fearless mutation like this is more idiomatic Rust.

I'll write up an example later this morning once I've had some coffee!