pub fn format_list(list: &[String]) -> StringExpand description
Formats a list of strings with commas and “and” if necessary. Uses the oxford comma.
Note: An attempt was made to genericize these functions to work with Vec<T : Display + Join>, but the Join trait is unstable.
§Examples
assert_eq!(format_list(
&vec![]),
"nothing");assert_eq!(format_list(&vec_string![
"Nona"]),
"Nona");assert_eq!(format_list(&vec_string![
"Nona", "Samantha"]),
"Nona and Samantha");assert_eq!(format_list(&vec_string![
"Nona", "Samantha", "Lucy", "Charles"]),
"Nona, Samantha, Lucy, and Charles");