pub fn sequence_to_str<T>(
sequence: &[T],
enclosing: Enclosing,
max_items: usize,
) -> Stringwhere
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 “and
E.g.:
- [a] => “a”
- [a, b] => “a” and “b”
- [a, b, c] => “a”, “b” and “c”
- [a, b, c, d] => “a”, “b”, “c” and one more
- [a, b, c, d, e] => “a”, “b”, “c” and two more
Panics if the sequence
is empty, or max_items
is zero.