Skip to main content

truncate_middle

Function truncate_middle 

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

Truncates a string in the middle, keeping start and end.

Useful for file paths or long identifiers where both ends are important.

ยงExample

use bel7_cli::truncate_middle;

let result = truncate_middle("/very/long/path/to/file.txt", 20);
assert!(result.len() <= 20);
assert!(result.contains("..."));