refactor: Remove extra layer of AnsiDisplay

This commit is contained in:
Ed Page 2023-03-16 13:23:20 -05:00
parent 1773884715
commit 6255229a9c

View file

@ -14,7 +14,7 @@ impl StyledStr {
/// Display using [ANSI Escape Code](https://en.wikipedia.org/wiki/ANSI_escape_code) styling
#[cfg(feature = "color")]
pub fn ansi(&self) -> impl std::fmt::Display + '_ {
AnsiDisplay { styled: self }
self.0.as_str()
}
pub(crate) fn header(&mut self, msg: impl Into<String>) {
@ -210,18 +210,6 @@ impl std::fmt::Display for StyledStr {
}
}
#[cfg(feature = "color")]
struct AnsiDisplay<'s> {
styled: &'s StyledStr,
}
#[cfg(feature = "color")]
impl std::fmt::Display for AnsiDisplay<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.styled.0.fmt(f)
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub(crate) enum Style {
Header,