I couldn’t find any docs on closures’ internal representation. Can anyone please explain how does it look like generally (in pseudocode maybe)?
The exact representation is unstable, and I guess that's intentional, since any explicit guarantee may inhibit optimizations and/or future features. Conceptually, every closure is a
struct with all captured values as fields and
Fn* implementations derived from body.
I remember someone recommending this link for some more explanation - can't check it right now myself, however.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.