Skip to content

Commit

Permalink
Constify Color methods
Browse files Browse the repository at this point in the history
Signed-off-by: jaudiger <[email protected]>
  • Loading branch information
jaudiger committed May 22, 2024
1 parent da5072d commit b00f521
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ impl Color {
/// let style = Color::Red.normal();
/// println!("{}", style.paint("hi"));
/// ```
pub fn normal(self) -> Style {
pub const fn normal(self) -> Style {
Style {
foreground: Some(self),
..Style::default()
..Style::new()
}
}

Expand All @@ -422,11 +422,11 @@ impl Color {
/// let style = Color::Green.bold();
/// println!("{}", style.paint("hey"));
/// ```
pub fn bold(self) -> Style {
pub const fn bold(self) -> Style {
Style {
foreground: Some(self),
is_bold: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -441,11 +441,11 @@ impl Color {
/// let style = Color::Yellow.dimmed();
/// println!("{}", style.paint("sup"));
/// ```
pub fn dimmed(self) -> Style {
pub const fn dimmed(self) -> Style {
Style {
foreground: Some(self),
is_dimmed: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -460,11 +460,11 @@ impl Color {
/// let style = Color::Blue.italic();
/// println!("{}", style.paint("greetings"));
/// ```
pub fn italic(self) -> Style {
pub const fn italic(self) -> Style {
Style {
foreground: Some(self),
is_italic: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -479,11 +479,11 @@ impl Color {
/// let style = Color::Purple.underline();
/// println!("{}", style.paint("salutations"));
/// ```
pub fn underline(self) -> Style {
pub const fn underline(self) -> Style {
Style {
foreground: Some(self),
is_underline: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -498,11 +498,11 @@ impl Color {
/// let style = Color::Cyan.blink();
/// println!("{}", style.paint("wazzup"));
/// ```
pub fn blink(self) -> Style {
pub const fn blink(self) -> Style {
Style {
foreground: Some(self),
is_blink: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -517,11 +517,11 @@ impl Color {
/// let style = Color::Black.reverse();
/// println!("{}", style.paint("aloha"));
/// ```
pub fn reverse(self) -> Style {
pub const fn reverse(self) -> Style {
Style {
foreground: Some(self),
is_reverse: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -536,11 +536,11 @@ impl Color {
/// let style = Color::White.hidden();
/// println!("{}", style.paint("ahoy"));
/// ```
pub fn hidden(self) -> Style {
pub const fn hidden(self) -> Style {
Style {
foreground: Some(self),
is_hidden: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -555,11 +555,11 @@ impl Color {
/// let style = Color::Fixed(244).strikethrough();
/// println!("{}", style.paint("yo"));
/// ```
pub fn strikethrough(self) -> Style {
pub const fn strikethrough(self) -> Style {
Style {
foreground: Some(self),
is_strikethrough: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -574,11 +574,11 @@ impl Color {
/// let style = Color::Fixed(244).reset_before_style();
/// println!("{}", style.paint("yo"));
/// ```
pub fn reset_before_style(self) -> Style {
pub const fn reset_before_style(self) -> Style {
Style {
foreground: Some(self),
prefix_with_reset: true,
..Style::default()
..Style::new()
}
}

Expand All @@ -593,11 +593,11 @@ impl Color {
/// let style = Color::Rgb(31, 31, 31).on(Color::White);
/// println!("{}", style.paint("eyyyy"));
/// ```
pub fn on(self, background: Color) -> Style {
pub const fn on(self, background: Color) -> Style {
Style {
foreground: Some(self),
background: Some(background),
..Style::default()
..Style::new()
}
}
}
Expand Down

0 comments on commit b00f521

Please sign in to comment.