From 0459219489d2fb8903cd1f4a114d03c5405b19fb Mon Sep 17 00:00:00 2001 From: jaudiger Date: Wed, 22 May 2024 08:36:30 +0200 Subject: [PATCH 1/2] constify Style constructor Signed-off-by: jaudiger --- src/style.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/style.rs b/src/style.rs index 3058767..0749cfa 100644 --- a/src/style.rs +++ b/src/style.rs @@ -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. @@ -262,7 +274,7 @@ impl Style { /// assert_eq!(false, Style::default().bold().is_plain()); /// ``` pub fn is_plain(self) -> bool { - self == Style::default() + self == Style::new() } } @@ -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() } } From da5072dbb82e6999897f2102bb744bb62bdfbbe1 Mon Sep 17 00:00:00 2001 From: jaudiger Date: Wed, 22 May 2024 08:37:00 +0200 Subject: [PATCH 2/2] resolve a typo: struckthrough -> strikethrough Signed-off-by: jaudiger --- src/style.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style.rs b/src/style.rs index 0749cfa..909f169 100644 --- a/src/style.rs +++ b/src/style.rs @@ -42,7 +42,7 @@ pub struct Style { /// Whether this style is hidden. pub is_hidden: bool, - /// Whether this style is struckthrough. + /// Whether this style is strikethrough. pub is_strikethrough: bool, /// Wether this style is always displayed starting with a reset code to clear any remaining style artifacts