Skip to content

Commit

Permalink
feat(antyle): Make on_default const
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 11, 2023
1 parent 41db129 commit fa31837
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/anstyle/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit fa31837

Please sign in to comment.