#ascii #tree

ascii_tree

generates ascii trees

2 releases

Uses old Rust 2015

0.1.1 Jun 5, 2018
0.1.0 Dec 12, 2017

#36 in #ascii

Download history 15/week @ 2021-02-20 17/week @ 2021-02-27 7/week @ 2021-03-06 13/week @ 2021-03-13 16/week @ 2021-03-20 9/week @ 2021-03-27 27/week @ 2021-04-03 58/week @ 2021-04-10 30/week @ 2021-04-17 24/week @ 2021-04-24 51/week @ 2021-05-01 44/week @ 2021-05-08 117/week @ 2021-05-15 7/week @ 2021-05-22 26/week @ 2021-05-29 18/week @ 2021-06-05

116 downloads per month
Used in 5 crates (2 directly)

MIT license

5KB

Crate to write an ascii tree.

 let l1 = Leaf(vec![String::from("line1"), String::from("line2"), String::from("line3"), String::from("line4")]);
 let l2 = Leaf(vec![String::from("only one line")]);
 let n1 = Node(String::from("node 1"), vec![l1.clone(), l2.clone()]);
 let n2 = Node(String::from("node 2"), vec![l2.clone(), l1.clone(), l2.clone()]);
 let n3 = Node(String::from("node 3"), vec![n1.clone(), l1.clone(), l2.clone()]);
 let n4 = Node(String::from("node 4"), vec![n1, n2, n3]);

 let mut output = String::new();
 let _ = write_tree(&mut output, &n4);

The result would be:

 node 4
 ├─ node 1
 │  ├─ line1
 │  │  line2
 │  │  line3
 │  │  line4
 │  └─ only one line
 ├─ node 2
 │  ├─ only one line
 │  ├─ line1
 │  │  line2
 │  │  line3
 │  │  line4
 │  └─ only one line
 └─ node 3
    ├─ node 1
    │  ├─ line1
    │  │  line2
    │  │  line3
    │  │  line4
    │  └─ only one line
    ├─ line1
    │  line2
    │  line3
    │  line4
    └─ only one line

No runtime deps