Debug Tree
This library allows you to build a tree one element at a time and output it as a pretty string. This is particularly convenient for generating clean output from nested and recursive functions. A design goal was to allow this library to be used as a drop-in replacement of println!(...)
.
Recursive Example
By adding the add_branch!(...)
macro at the start of a recursive function, you can see the entire call tree, instantly.
use ;
6
├╼ 1
├╼ 2
│ └╼ 1
└╼ 3
└╼ 1
Nested Example
Branches also make nested function calls a lot easier to follow.
use ;
a
├╼ b
│ └╼ c
│ └╼ Nothing to see here
└╼ c
└╼ Nothing to see here
Line Breaks
Newlines in multi-line strings are automatically indented.
use ;
1
├╼ 1.1
│ Next line
└╼ 1.2
Non-Macro Version
In the case that multiple trees are needed, the trees can be created manually without the helper macros.
use TreeBuilder;
1 Branch
└╼ 1.1 Child
2 Sibling