Logo

Programming-Idioms

History of Idiom 17 > diff from v52 to v53

Edit summary for version 53 by programming-idioms.org:
[Rust] +DemoURL

Version 52

2020-10-11, 00:22:27

Version 53

2021-02-26, 08:53:12

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<Node<T>>,
}
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4b4e6d41f416f42388ab693edaadf079