Logo

Programming-Idioms

History of Idiom 9 > diff from v22 to v23

Edit summary for version 23 by programming-idioms.org:
[Rust] Missing comma, iiuc

Version 22

2016-11-23, 10:23:01

Version 23

2016-11-29, 09:00:55

Idiom #9 Create a Binary Tree data structure

The structure must be recursive because left child and right child are binary trees too. A node has access to children nodes, but not to its parent.

Idiom #9 Create a Binary Tree data structure

The structure must be recursive because left child and right child are binary trees too. A node has access to children nodes, but not to its parent.

Code
struct BinTree<T> {
    value: T
    left: Option<Box<BinTree<T>>>,
    right: Option<Box<BinTree<T>>>,
}
Code
struct BinTree<T> {
    value: T,
    left: Option<Box<BinTree<T>>>,
    right: Option<Box<BinTree<T>>>,
}