4 ms·
I've had no issues with tree structures: enum BinaryTree { Leaf(i32), Node(BinaryTree, BinaryTree) } But perhaps there are some operatio
by winstonewert 10y ago
I've had no issues with tree structures:
enum BinaryTree {
Leaf(i32),
Node(BinaryTree, BinaryTree)
}
But perhaps there are some operations you are doing on the tree that are more difficult?
Also, what kind of undirected graphs do you find yourself writing? I'm curious, because I rarely if ever find myself needing a graph.
- m1el 10y agoThis struct doesn't compile: recursive type `BinaryTree` has infinite size
- steveklabnik 10y agoSimplest solution: enum BinaryTree { Leaf(i32), Node(Box<BinaryTree>, Box<BinaryTree>) }
- winstonewert 10y agoMy bad. In my actual code I was thinking of it was a Vec<>, because my nodes aren't binary.