1use ecow::EcoString;
2use compose_library::Vm;
3
4pub fn separated_list(pieces: &[impl AsRef<str>], last: &str) -> String {
5 let mut buf = String::new();
6 for (i, part) in pieces.iter().enumerate() {
7 match i {
8 0 => {}
9 1 if pieces.len() == 2 => {
10 buf.push(' ');
11 buf.push_str(last);
12 buf.push(' ');
13 }
14 i if i + 1 == pieces.len() => {
15 buf.push_str(", ");
16 buf.push_str(last);
17 buf.push(' ');
18 }
19 _ => buf.push_str(", "),
20 }
21 buf.push_str(part.as_ref());
22 }
23 buf
24}
25
26pub trait Repr {
27 fn repr(&self, vm: &dyn Vm) -> EcoString;
28}