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

Function truncate

atomic-agent/src/provenance/consolidate.rs:730–737  ·  view source on GitHub ↗

Truncate a string for display.

(s: &str, max_len: usize)

Source from the content-addressed store, hash-verified

728
729/// Truncate a string for display.
730fn truncate(s: &str, max_len: usize) -> String {
731 if s.len() <= max_len {
732 s.to_string()
733 } else {
734 let truncated: String = s.chars().take(max_len.saturating_sub(3)).collect();
735 format!("{}...", truncated)
736 }
737}
738
739// =============================================================================
740// Tests

Callers 6

renderMethod · 0.85
test_table_truncationFunction · 0.85
detect_full_cycleFunction · 0.85
detect_commit_and_verifyFunction · 0.85

Calls 1

lenMethod · 0.45

Tested by 3

test_table_truncationFunction · 0.68