Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/interfaces/libpq/po/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 70 kB image not shown  

Impressum color.rs   Sprache: unbekannt

 
#[derive(Copy, Clone, Debug, Default)]
pub(cratestruct Palette {
    description: anstyle::Style,
    var: anstyle::Style,
    expected: anstyle::Style,
}

impl Palette {
    pub(cratefn new(alternate: bool) -> Self {
        if alternate && cfg!(feature = "color") {
            Self {
                description: anstyle::AnsiColor::Blue.on_default() | anstyle::Effects::BOLD,
                var: anstyle::AnsiColor::Red.on_default() | anstyle::Effects::BOLD,
                expected: anstyle::AnsiColor::Green.on_default() | anstyle::Effects::BOLD,
            }
        } else {
            Self::plain()
        }
    }

    pub(cratefn plain() -> Self {
        Self {
            description: Default::default(),
            var: Default::default(),
            expected: Default::default(),
        }
    }

    pub(cratefn description<D: std::fmt::Display>(self, display: D) -> Styled<D> {
        Styled::new(display, self.description)
    }

    pub(cratefn var<D: std::fmt::Display>(self, display: D) -> Styled<D> {
        Styled::new(display, self.var)
    }

    pub(cratefn expected<D: std::fmt::Display>(self, display: D) -> Styled<D> {
        Styled::new(display, self.expected)
    }
}

#[derive(Debug)]
pub(cratestruct Styled<D> {
    display: D,
    style: anstyle::Style,
}

impl<D: std::fmt::Display> Styled<D> {
    pub(cratefn new(display: D, style: anstyle::Style) -> Self {
        Self { display, style }
    }
}

impl<D: std::fmt::Display> std::fmt::Display for Styled<D> {
    #[inline]
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        if f.alternate() {
            write!(f, "{}"self.style.render())?;
            self.display.fmt(f)?;
            write!(f, "{}"self.style.render_reset())?;
            Ok(())
        } else {
            self.display.fmt(f)
        }
    }
}

Messung V0.5 in Prozent
C=84 H=88 G=85

[Seitenstruktur0.13Druckenetwas mehr zur Ethik2026-08-25]