Function wagon_utils::comma_separated_with_or
source · pub fn comma_separated_with_or(strings: &[String]) -> String
Expand description
Given a vector of strings, return a string that has all the values joined by a ,
. Except for the last which is joined by or
.
§Example
use wagon_utils::comma_separated_with_or;
let v = vec!["1".to_string(), "2".to_string(), "3".to_string()];
assert_eq!("1, 2 or 3".to_string(), comma_separated_with_or(&v));
let v = vec!["1".to_string()];
assert_eq!("1".to_string(), comma_separated_with_or(&v));
let v = vec![];
assert_eq!("".to_string(), comma_separated_with_or(&v));