MCPcopy Create free account
hub / github.com/AIScientists-Dev/Flowtrace / wrap

Function wrap

crates/flowtrace-cli/src/explain.rs:554–578  ·  view source on GitHub ↗

Simple word-wrap for the description block.

(text: &str, width: usize)

Source from the content-addressed store, hash-verified

552
553/// Simple word-wrap for the description block.
554fn wrap(text: &str, width: usize) -> Vec<String> {
555 let mut out: Vec<String> = vec![];
556 for paragraph in text.split('\n') {
557 let mut line = String::new();
558 for word in paragraph.split_whitespace() {
559 if line.is_empty() {
560 line.push_str(word);
561 } else if line.len() + 1 + word.len() <= width {
562 line.push(' ');
563 line.push_str(word);
564 } else {
565 out.push(line.clone());
566 line.clear();
567 line.push_str(word);
568 }
569 }
570 if !line.is_empty() {
571 out.push(line);
572 }
573 }
574 if out.is_empty() {
575 out.push(String::new());
576 }
577 out
578}
579
580#[cfg(test)]
581mod tests {

Callers 1

render_plaintextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…