pub fn preview_text(text: &str, max_len: usize) -> Cow<'_, str>Expand description
At most max_len bytes of text, carriage returns removed. Longer
text is cut at a character boundary and, when max_len is 7 or more,
ends with ... (counted in max_len). Borrowed when the text fits and
has no carriage return.
use mail_parser::preview_text;
assert_eq!(preview_text("Hello,\r\nworld", 20), "Hello,\nworld");
assert_eq!(preview_text("Hello, world", 8), "Hello...");