1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fmt;

pub struct CommaSep<'a, T>(pub &'a [T]);

impl<'a, T> fmt::Display for CommaSep<'a, T>
where
    T: fmt::Display,
{
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut sep = "";
        for item in self.0 {
            write!(f, "{}{}", sep, item)?;
            sep = ", ";
        }
        Ok(())
    }
}