If you don’t have a perf requirement like “all these things need to be in contiguous memory” then you probably don’t need a generational index anyway… it is effectively a weak reference, after all. ECS stores are optimised for repeatedly iterating over all the things, and games might have complex notions of “reachability”, but most things aren’t like that. There does seem to be a lot of “I don’t like using Rc RefCell” in object arena design that isn’t always justifiable, though nested generics don’t make for the most readable code in the world.
[@rust](https://programming.dev/c/rust) Blog post: Mutable object trees in Rust, using memory arenas
[@rust](https://programming.dev/c/rust) Blog post: Mutable object trees in Rust, using memory arenas
You can always use something like generational indices. They pop up a lot in ECS systems. A suitable container with an opaque index type prevents creation of invalid references, lets you check reference validity at runtime, and generational indices prevent reuse. The compiler can’t help with lifetime tracking, but that’s a problem with any shared reference type pointing to a resource with a lifetime that can only be known at runtime, eg. Arc.
rook
joined 2 years ago
Everyone and their dog uses mathjax or katex to render math client-side these days. I’m not gonna say that it would be trivial, but it also shouldn’t require you to get elbow-deep in lemmy’s own post-formatting code.
Unfortunately, there’s no obvious prior art that can be stolen here, and there’s only one slightly confused feature request in the lemmy-ui repo, so someone is going to have to nail all the bits together themselves.