Skip to main content

join_with_conjunction

Function join_with_conjunction 

Source
pub fn join_with_conjunction(
    items: &[&str],
    separator: &str,
    conjunction: &str,
) -> String
Expand description

Join items with a separator and a final conjunction.

ยงExample

use click::utils::join_with_conjunction;

let items = vec!["a", "b", "c"];
assert_eq!(join_with_conjunction(&items, ", ", " or "), "a, b or c");

let items = vec!["a", "b"];
assert_eq!(join_with_conjunction(&items, ", ", " and "), "a and b");

let items = vec!["a"];
assert_eq!(join_with_conjunction(&items, ", ", " and "), "a");