this post was submitted on 24 Oct 2023
16 points (94.4% liked)

Rust

6058 readers
66 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
top 7 comments
sorted by: hot top controversial new old
[–] [email protected] 7 points 1 year ago

I like this approach for Rust in general when it comes to graphs. But it suffers from many of the same kinds of issues we get with pointers, e.g. dangling pointers, use after free, and so on. Tradeoffs!

[–] [email protected] 6 points 1 year ago (1 children)

If you want to go one step further, a lot of game development uses a generational index, where the index is both a value and a generation, allowing you to know whether the index you currently have stored references an object that has already been destroyed and replaced by another object. Basically every ECS framework I've ever seen uses this pattern.

[–] [email protected] 3 points 1 year ago (1 children)

Interesting. Can you provide a good link regarding generational index?

[–] [email protected] 3 points 1 year ago (2 children)

I was originally introduced to the idea by this RustConf 2018 keynote: https://kyren.github.io/2018/09/14/rustconf-talk.html. It's rather dense though.

I did find this random article that outlines just the concept of generational indices pretty concisely: https://lucassardois.medium.com/generational-indices-guide-8e3c5f7fd594

[–] [email protected] 2 points 1 year ago
[–] [email protected] 2 points 1 year ago (1 children)

That same keynote is linked in the last paragraph! :) The slotmap crate is also one option for generational indexes.

[–] [email protected] 1 points 1 year ago

Ah, you're right! Somehow I missed that, good catch.