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

Method render

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

Source from the content-addressed store, hash-verified

242 }
243
244 fn render(&self) -> String {
245 fn clean(label: &str) -> String {
246 label
247 .chars()
248 .map(|c| if c.is_control() { ' ' } else { c })
249 .collect()
250 }
251 let mut out = format!("{}\n", clean(&self.label));
252 let mut pending: Vec<_> = self
253 .children
254 .iter()
255 .enumerate()
256 .rev()
257 .map(|(i, child)| (child, String::new(), i + 1 == self.children.len()))
258 .collect();
259 while let Some((node, prefix, last)) = pending.pop() {
260 let branch = if last { "└──" } else { "├──" };
261 out.push_str(&format!("{prefix}{branch} {}\n", clean(&node.label)));
262 let prefix = format!("{prefix}{}", if last { " " } else { "│ " });
263 for (i, child) in node.children.iter().enumerate().rev() {
264 pending.push((child, prefix.clone(), i + 1 == node.children.len()));
265 }
266 }
267 out
268 }
269}
270
271fn 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