MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / format_compact_annotated_path_list

Function format_compact_annotated_path_list

src/path_tree.rs:40–63  ·  view source on GitHub ↗
(
    paths: impl IntoIterator<Item = (&'a str, S)>,
    bullet_prefix: &str,
    tree_prefix: &str,
)

Source from the content-addressed store, hash-verified

38}
39
40pub(crate) fn format_compact_annotated_path_list<'a, S>(
41 paths: impl IntoIterator<Item = (&'a str, S)>,
42 bullet_prefix: &str,
43 tree_prefix: &str,
44) -> String
45where
46 S: AsRef<str>,
47{
48 let mut root = PathNode::default();
49 let mut bullet_lines = Vec::new();
50 for (path, suffix) in paths {
51 let suffix = suffix.as_ref();
52 bullet_lines.push(format!("{bullet_prefix}{path}{suffix}"));
53 root.insert(path, suffix);
54 }
55
56 let bullet_list = bullet_lines.join("\n");
57 let tree = prefix_lines(&render_path_tree(&root), tree_prefix);
58 if has_directory_shape(&root) && tree.len() < bullet_list.len() {
59 tree
60 } else {
61 bullet_list
62 }
63}
64
65fn render_path_tree(root: &PathNode) -> String {
66 let mut lines = Vec::new();

Callers 4

format_compact_path_listFunction · 0.85
preserves_leaf_suffixesFunction · 0.85

Calls 5

prefix_linesFunction · 0.85
render_path_treeFunction · 0.85
has_directory_shapeFunction · 0.85
pushMethod · 0.80
insertMethod · 0.80

Tested by 2

preserves_leaf_suffixesFunction · 0.68