Function sequence_to_str_or

Source
pub fn sequence_to_str_or<T>(
    sequence: &[T],
    enclosing: Enclosing,
    max_items: usize,
) -> String
where T: Display,
Expand description

Returns reading-friendly textual representation of the sequence, with comma-separated items and each item optionally enclosed in the specified enclosing. If the sequence has more than max_items the remaining items are replaced with the text “or more”.

E.g.:

  • [a] => “a”
  • [a, b] => “a” or “b”
  • [a, b, c] => “a”, “b” or “c”
  • [a, b, c, d] => “a”, “b”, “c” or one more
  • [a, b, c, d, e] => “a”, “b”, “c” or two more

Panics if the sequence is empty, or max_items is zero.