What is the equivalent of the join operator over a vector of Strings?

I wasn’t able to find the Rust equivalent for the “join” operator over a vector of Strings. I have a Vec<String> and I’d like to join them as a single String:

let string_list = vec!["Foo".to_string(),"Bar".to_string()];
let joined = something::join(string_list,"-");
assert_eq!("Foo-Bar", joined);

Related:

  • What’s an idiomatic way to print an iterator separated by spaces in Rust?

3 Answers
3

Leave a Comment