truncate_string

Function truncate_string 

Source
pub fn truncate_string(text: &str, max_length: usize) -> String
Expand description

Truncate a string to a maximum length, adding ellipsis if truncated

ยงExamples

use agents_core::security::truncate_string;

let short = "Hello";
assert_eq!(truncate_string(short, 100), "Hello");

let long = "a".repeat(150);
let truncated = truncate_string(&long, 100);
assert_eq!(truncated.len(), 103); // 100 chars + "..."
assert!(truncated.ends_with("..."));