Constructs a new binary tree with the given number of layers.
(layers: usize)
| 17 | impl Node { |
| 18 | // Constructs a new binary tree with the given number of layers. |
| 19 | pub fn tree(layers: usize) -> Self { |
| 20 | Self { |
| 21 | val: 1, |
| 22 | left: (layers != 1).then(|| Box::new(Self::tree(layers - 1))), |
| 23 | right: (layers != 1).then(|| Box::new(Self::tree(layers - 1))), |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | // Returns an iterator over the number of layers. Also returns the total number |
nothing calls this directly
no outgoing calls
no test coverage detected