Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(antyle): Make on_default const #123

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading