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

We are copying the reference to the data, not the data itself. The reference to the data lasts for the lifetime of the program. Generational box lets you insert data that last for shorter than the lifetime of the program (as long as that data contains no references). Once you drop the data you inserted, we reuse the box for other allocations.

It uses a very similar approach to a generational arena but with boxes instead of a centralized arena (to avoid locking issues). If you try to access the Copy reference to the data after it has been dropped, it will fail with a nice error message




Thanks. Iā€™m wondering if this allows for non-static data at all? Maybe it has to be either static or copyable?


All data you insert into a generational box needs to be allowed to last for the 'static lifetime (have no internal temporary pointers). You cannot insert something like &'a str into a generational box




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

Search: