egglog_ast/
util.rs

1use std::fmt::Display;
2
3pub struct ListDisplay<'a, TS>(pub TS, pub &'a str);
4
5impl<TS> Display for ListDisplay<'_, TS>
6where
7    TS: Clone + IntoIterator,
8    TS::Item: Display,
9{
10    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11        let mut did_something = false;
12        for item in self.0.clone().into_iter() {
13            if did_something {
14                f.write_str(self.1)?;
15            }
16            Display::fmt(&item, f)?;
17            did_something = true;
18        }
19        Ok(())
20    }
21}