Trait rosary::format::TreeFormat

source ·
pub trait TreeFormat {
    // Required method
    fn treeify(&self) -> RoseVecTree<String>;

    // Provided methods
    fn indent(&self) -> RoseVecTree<String> { ... }
    fn fmt_tree(&self) -> String { ... }
}
Expand description

A trait which allows implementers to specify how they should be printed as a tree.

Required Methods§

source

fn treeify(&self) -> RoseVecTree<String>

The only thing you need to define is the conversion from your type to a RoseVecTree.

Provided Methods§

source

fn indent(&self) -> RoseVecTree<String>

Indent adds the decorations to the strings of the tree with the default formatter.

source

fn fmt_tree(&self) -> String

Actually converts the tree into a single string for printing.

Trait Implementations§

source§

impl Display for dyn TreeFormat

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§

source§

impl<T: Display> TreeFormat for RoseVecTree<T>

If you’re a RoseVecTree, you get TreeFormat for free so long as T can be printed. If printing T involves printing newlines, don’t. It’ll get weird.