mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
refactor: Remove extra layer of AnsiDisplay
This commit is contained in:
parent
1773884715
commit
6255229a9c
1 changed files with 1 additions and 13 deletions
|
@ -14,7 +14,7 @@ impl StyledStr {
|
||||||
/// Display using [ANSI Escape Code](https://en.wikipedia.org/wiki/ANSI_escape_code) styling
|
/// Display using [ANSI Escape Code](https://en.wikipedia.org/wiki/ANSI_escape_code) styling
|
||||||
#[cfg(feature = "color")]
|
#[cfg(feature = "color")]
|
||||||
pub fn ansi(&self) -> impl std::fmt::Display + '_ {
|
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>) {
|
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)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub(crate) enum Style {
|
pub(crate) enum Style {
|
||||||
Header,
|
Header,
|
||||||
|
|
Loading…
Add table
Reference in a new issue