Hacker News new | ask | show | jobs
by vmchale 2123 days ago
> how many function types does Rust have again? Three?

It has to, right? ATS has many function types as well, plus stack-allocated closures (I think Rust has that too??)

2 comments

Rust's closures do not heap allocate unless you box them, like any other struct, because closures are sugar for a struct + a function, that's correct.

(and yes, there are three types of closures, because they need to know if they take said struct by reference, by mutable reference, or by owner.)

It does have to, because of the way mutation and ownership work. Which is great! But it makes functional programming awkward. The language does not "steward" you toward function composition.