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

Function truncate_display

atomic-cli/src/commands/query/mod.rs:1151–1158  ·  view source on GitHub ↗

Truncate display text on character boundaries and append `...`.

(s: &str, max_chars: usize)

Source from the content-addressed store, hash-verified

1149
1150/// Truncate display text on character boundaries and append `...`.
1151pub(crate) fn truncate_display(s: &str, max_chars: usize) -> String {
1152 if s.chars().count() <= max_chars {
1153 s.to_string()
1154 } else {
1155 let kept: String = s.chars().take(max_chars.saturating_sub(3)).collect();
1156 format!("{}...", kept)
1157 }
1158}
1159
1160/// Search the knowledge graph.
1161#[derive(Parser, Debug)]

Calls 2

countMethod · 0.45
collectMethod · 0.45