join_iterator_and_add_back

Function join_iterator_and_add_back 

Source
pub fn join_iterator_and_add_back<T: ToString + Sized, U: Iterator<Item = T>, S: Into<String>>(
    list: U,
    sep: S,
) -> String
Expand description

Join iterators over string types using the given separator and add separator at the end

This function can be used to join iterators over string types using the given separator. The separator can be any string, including an empty string. It will also be appended to the end of the resulting string, except if the string is empty.

ยงExample

use taco_display_utils::join_iterator_and_add_back;

let list = vec!["a", "b", "c"];
assert_eq!(join_iterator_and_add_back(list.iter(), ", "), "a, b, c, ");

let list: Vec<&str> = vec![];
assert_eq!(join_iterator_and_add_back(list.iter(), ", "), "");