> <i>Programming in a functional style often includes using functions as values by passing them in arguments, returning them from other functions, assigning them to variables for later execution, and so forth.</i><p>> ...<p>> <i>Other Rust features, such as pattern matching and enums, which we’ve covered in other chapters, are influenced by the functional style as well.</i><p>What is it about pattern matching and enums that associates them with functional programming? Because going by the description of functional programming above, I don't see how they fit in. Is it just that pattern matching and enums were first popularized by certain functional languages?
How are iterators functional language features? They're not unique to functional languages and they don't require function composition to implement. They're present in most popular imperative languages.
I've tried to use iterators and closures in my code, but it's not as easy with error handling and lifetimes. Like I could figure out the magic incantation that lets me map over an iterator with a function that returns a result. Or I could write a for loop that pushes to a Vec.<p>Or I could chain an ok_or_else on an Option but ugh now Rust is complaining that I'm capturing a reference to self. Screw it, I'll rewrite it to be an if let with a return. Part of the problem there is that we know an ok_or_else with try! will execute the closure and return if the value is None, but Rust's borrow check doesn't know that.<p>None of this is Rust's fault. It's just that it's hard to combine ergonomic closures and borrow checking.