Logo

Programming-Idioms

History of Idiom 17 > diff from v43 to v44

Edit summary for version 44 by Worik:
[Rust] The size of `Node` must be known at compile time.

Version 43

2019-09-27, 10:18:08

Version 44

2019-09-27, 22:18:43

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Code
struct Node<T> {
  value: T,
  children: Vec<Node<T>>,
}
Code
struct Node<T> {
  value: T,
  children: Vec<Box<Node<T>>>,
}
Comments bubble
Must be boxed. Size must be known at compile time