Skip to main content

truncate_with_marker

Function truncate_with_marker 

Source
pub fn truncate_with_marker(s: &str, max_chars: usize, marker: &str) -> String
Expand description

s, or its first max_chars characters followed by marker when it is longer. The result is max_chars plus the marker at most.

use gemini_adk_rs::utils::text::truncate_with_marker;

assert_eq!(truncate_with_marker("héllo wörld", 5, "…"), "héllo…");
assert_eq!(truncate_with_marker("héllo", 5, "…"), "héllo");