macro_rules! writeln_tree {
($f:expr, $tree:expr $(,)?) => { ... };
($f:expr, $tree:expr, $style:expr $(,)?) => { ... };
}
Expand description
Writes a type that implements DisplayTree
to a buffer as a tree, with a
newline.
A Style
can be passed as the second argument to customize the way the
tree is formatted.
§Examples
use display_tree::writeln_tree;
#[derive(display_tree::DisplayTree)]
struct Tree;
let mut buf = Vec::new();
writeln_tree!(&mut buf, Tree);
assert_eq!(&buf, "Tree\n".as_bytes());
Specifying a style:
use display_tree::{writeln_tree, CharSet, Style, StyleBuilder};
#[derive(display_tree::DisplayTree)]
struct Tree {
a: i32,
b: bool,
}
let mut buf = Vec::new();
writeln_tree!(
&mut buf,
Tree { a: 1, b: true },
Style::default().char_set(CharSet::SINGLE_LINE_BOLD)
);
assert_eq!(
&buf,
"Tree\n\
┣━━ 1\n\
┗━━ true\n"
.as_bytes()
);