this post was submitted on 15 Mar 2025
21 points (95.7% liked)
Rust
6697 readers
102 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
One way to do this is to use reference-counting pointers such as
std::rc::Rc
orstd::sync:Arc
. The parent node can hold a strong reference to each child node and each child node has aWeak
reference to its parent.I guess that's possible. The sibling pointers can also be weakrefs, I think. I don't know if there are ever arbitrary links between DOM nodes rather than just the tree-like ones. But, you are onto something if creation of weakrefs safely avoids the pointer ownership rules. I'll have to look into this further.