Skip to main content

join_with_overflow

Function join_with_overflow 

Source
pub fn join_with_overflow(
    items: &[String],
    total: usize,
    max: usize,
    label: &str,
) -> String
Expand description

Join items into a newline-separated string, appending an overflow hint when total > max.

§Examples

use rtk::utils::join_with_overflow;
let items = vec!["a".to_string(), "b".to_string()];
assert_eq!(join_with_overflow(&items, 5, 3, "items"), "a\nb\n… +2 more items");
assert_eq!(join_with_overflow(&items, 2, 3, "items"), "a\nb");