Loading RustViz Engine...
Prevent memory leaks in bidirectional tree nodes using Weak parent pointers.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
use std::rc::{Rc, Weak};
use std::cell::RefCell;
pub struct TreeNode {
pub val: i32,
pub parent: RefCell<Weak<TreeNode>>,
pub children: RefCell<Vec<Rc<TreeNode>>>,
}