Function format

Source
pub fn format(
    tree: &str,
    children: Vec<String>,
    symbols: &dyn Symbols,
) -> String
Expand description

Very inefficiently formats the given node and children into a tree by indenting every line.

use ast2str::{DefaultSymbols, builder::format};

let output = format(
    "A",
    vec![
        format("B", vec!["b1".to_string(), "b2".to_string(), "b3".to_string()], &DefaultSymbols),
        format("C", vec![format("D", vec!["d1".to_string(), "d2".to_string()], &DefaultSymbols)], &DefaultSymbols)
    ],
    &DefaultSymbols
);
assert_eq!(output, r#"
A
├─B
│ ├─b1
│ ├─b2
│ ╰─b3
╰─C
  ╰─D
    ├─d1
    ╰─d2
"#.trim());