Hacker News new | past | comments | ask | show | jobs | submit login

A closure in Rust is just a struct containing its captures either by value or as & or &mut references pointing to the values. Thus, making/avoiding a cycle with them is the same as doing it for "normal" values.

One can't accidentally get a reference-counting cycle (values aren't reference counted unless they're put into a pointer explicitly), and a cycle of shared/mutable references won't stop deallocation (and, if it's a cycle that's unsafe, it won't compile).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: