• 0 Posts
  • 10 Comments
Joined 2 years ago
cake
Cake day: July 10th, 2023

help-circle

  • There are a few different ways to solve this problem without using unsafe and I’m not sure what would be considered idiomatic. Another option is to ultimately encapsulate all of the nodes in a reference-counted box like Rc or Arc and specify the type of your parent/child/sibling references to the same reference-counted box type. With that, you just share cloned instances around as needed.

    The primary drawback here is that for mutable access you end up having to perform a lock every time on an underlying Mutex (or something similar). You also no longer have direct access to the singular instance of the node.

    There are pros and cons to every approach.


  • One way of solving this is to structure all of your nodes into a HashMap with the node ID as the key and the node type as the value. The underlying node type could have node IDs for referencing purposes. You lose the ability to reference the parent/child/sibling directly, but you avoid direct circular dependencies. That said, now you need to manage dangling references for when the node is removed from the main HashMap collection.








  • Great list! I would just add The Majority Report if you’re looking to learn more about politics while also trying to understand what is happening today. They do a ~2.5-hour live show every weekday which includes a quick overview of the latest headlines for today, an interview of someone with knowledge about some politics-related topic, and then an hour of mostly right wing videos that they discuss, argue with, and vent about.

    I love it for how informative it is and for keeping me sane.