macro_rules! format_tree {
    ($tree:expr $(,)?) => { ... };
    ($tree:expr, $style:expr $(,)?) => { ... };
}
Expand description

Creates a String from a type that implements DisplayTree, formatting it as a tree.

A Style can be passed as the second argument to customize the way the tree is formatted.

Examples

use display_tree::format_tree;

#[derive(display_tree::DisplayTree)]
struct Tree;

assert_eq!(format_tree!(Tree), "Tree")

Specifying a style:

use display_tree::{format_tree, Style, StyleBuilder};

#[derive(display_tree::DisplayTree)]
struct Tree {
    a: i32,
    b: bool,
}

assert_eq!(
    format_tree!(Tree { a: 1, b: true }, Style::default().indentation(1)),
    "Tree\n\
     ├─ 1\n\
     └─ true"
);