Skip to content

Commit

Permalink
feat: allow construct Style constantly
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun authored Aug 5, 2024
1 parent 0912f8f commit 1fc04df
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,20 @@ impl Style {
/// let style = Style::new();
/// println!("{}", style.paint("hi"));
/// ```
pub fn new() -> Style {
Style::default()
pub const fn new() -> Style {
Style {
foreground: None,
background: None,
is_bold: false,
is_dimmed: false,
is_italic: false,
is_underline: false,
is_blink: false,
is_reverse: false,
is_hidden: false,
is_strikethrough: false,
prefix_with_reset: false,
}
}

/// Returns a [`Style`] with the `Style.prefix_with_reset` property set.
Expand Down Expand Up @@ -278,19 +290,7 @@ impl Default for Style {
/// assert_eq!("txt", Style::default().paint("txt").to_string());
/// ```
fn default() -> Style {
Style {
foreground: None,
background: None,
is_bold: false,
is_dimmed: false,
is_italic: false,
is_underline: false,
is_blink: false,
is_reverse: false,
is_hidden: false,
is_strikethrough: false,
prefix_with_reset: false,
}
Style::new()
}
}

Expand Down

0 comments on commit 1fc04df

Please sign in to comment.