MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / render

Method render

atomic-canonical/src/render.rs:286–310  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

284 }
285
286 fn render(&self) -> String {
287 fn clean(label: &str) -> String {
288 label
289 .chars()
290 .map(|c| if c.is_control() { ' ' } else { c })
291 .collect()
292 }
293 let mut out = format!("{}\n", clean(&self.label));
294 let mut pending: Vec<_> = self
295 .children
296 .iter()
297 .enumerate()
298 .rev()
299 .map(|(i, child)| (child, String::new(), i + 1 == self.children.len()))
300 .collect();
301 while let Some((node, prefix, last)) = pending.pop() {
302 let branch = if last { "└──" } else { "├──" };
303 out.push_str(&format!("{prefix}{branch} {}\n", clean(&node.label)));
304 let prefix = format!("{prefix}{}", if last { " " } else { "│ " });
305 for (i, child) in node.children.iter().enumerate().rev() {
306 pending.push((child, prefix.clone(), i + 1 == node.children.len()));
307 }
308 }
309 out
310 }
311}
312
313fn render_memory_cli(node: &MemoryNode) -> String {

Callers 1

render_cliFunction · 0.45

Calls 5

collectMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected