2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2021-07-28 18:06:57 -07:00
|
|
|
|
|
|
|
pub(crate) trait ColorDisplay {
|
2022-09-11 02:25:38 -07:00
|
|
|
fn color_display(&self, color: Color) -> Wrapper
|
2021-07-28 18:06:57 -07:00
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
{
|
|
|
|
Wrapper(self, color)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) struct Wrapper<'a>(&'a dyn ColorDisplay, Color);
|
|
|
|
|
|
|
|
impl<'a> Display for Wrapper<'a> {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
|
|
self.0.fmt(f, self.1)
|
|
|
|
}
|
|
|
|
}
|