From fa31837e082c977910d74ba9c28f09815cb64417 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 11 Sep 2023 09:08:41 -0500 Subject: [PATCH] feat(antyle): Make on_default const --- crates/anstyle/src/color.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/anstyle/src/color.rs b/crates/anstyle/src/color.rs index a0d17c31..25355627 100644 --- a/crates/anstyle/src/color.rs +++ b/crates/anstyle/src/color.rs @@ -17,7 +17,7 @@ impl Color { /// Create a [`Style`][crate::Style] with this as the foreground #[inline] - pub fn on_default(self) -> crate::Style { + pub const fn on_default(self) -> crate::Style { crate::Style::new().fg_color(Some(self)) } @@ -185,8 +185,8 @@ impl AnsiColor { /// Create a [`Style`][crate::Style] with this as the foreground #[inline] - pub fn on_default(self) -> crate::Style { - crate::Style::new().fg_color(Some(self.into())) + pub const fn on_default(self) -> crate::Style { + crate::Style::new().fg_color(Some(Color::Ansi(self))) } /// Render the ANSI code for a foreground color @@ -340,8 +340,8 @@ impl Ansi256Color { /// Create a [`Style`][crate::Style] with this as the foreground #[inline] - pub fn on_default(self) -> crate::Style { - crate::Style::new().fg_color(Some(self.into())) + pub const fn on_default(self) -> crate::Style { + crate::Style::new().fg_color(Some(Color::Ansi256(self))) } #[inline] @@ -460,8 +460,8 @@ impl RgbColor { /// Create a [`Style`][crate::Style] with this as the foreground #[inline] - pub fn on_default(self) -> crate::Style { - crate::Style::new().fg_color(Some(self.into())) + pub const fn on_default(self) -> crate::Style { + crate::Style::new().fg_color(Some(Color::Rgb(self))) } #[inline]