From 6255229a9c6f0d7340157e5b2dae2536de7c5199 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 16 Mar 2023 13:23:20 -0500 Subject: [PATCH] refactor: Remove extra layer of AnsiDisplay --- clap_builder/src/builder/styled_str.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/clap_builder/src/builder/styled_str.rs b/clap_builder/src/builder/styled_str.rs index 3871e441..3e15a637 100644 --- a/clap_builder/src/builder/styled_str.rs +++ b/clap_builder/src/builder/styled_str.rs @@ -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) { @@ -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,