by s_c_r on 6/24/20, 2:27 PM with 39 comments
by rectang on 6/24/20, 2:59 PM
> ...
> Other Rust features, such as pattern matching and enums, which we’ve covered in other chapters, are influenced by the functional style as well.
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?
by avodonosov on 6/24/20, 3:33 PM
by neuroticfish on 6/25/20, 12:34 AM
by _hardwaregeek on 6/24/20, 3:48 PM
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.
None of this is Rust's fault. It's just that it's hard to combine ergonomic closures and borrow checking.
by gdsdfe on 6/24/20, 9:47 PM