Comment

Comment by skybrian

I’m not a Rust programmer, but I’m curious, and I’m wondering if someone could explain how their generational-box crate works? [1]

I understand that it’s some kind of arena allocation, but I don’t understand how they support copying without copying, or how this is safe:

> Internally, generational-box creates an arena of generational RefCell's that are recycled when the owner is dropped. You can think of the cells as something like &'static RefCell<Box<dyn Any>> with a generational check to make recycling a cell easier to debug. Then GenerationalBox's are Copy because the &'static pointer is Copy

Like okay, you can create a pointer to static data, but what if it’s something that doesn’t have a static lifetime?

[1] https://crates.io/crates/generational-box

parent skybrian 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton