Skip to content

Commit

Permalink
Merge pull request #123 from epage/const
Browse files Browse the repository at this point in the history
feat(antyle): Make on_default const
  • Loading branch information
epage authored Sep 11, 2023
2 parents 41db129 + fa31837 commit 7691517
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 7691517

Please sign in to comment.