From 808a5c9ffdaf6df3cb00b2d1e5c55474e30b4fcd Mon Sep 17 00:00:00 2001 From: Malte Tammena Date: Mon, 20 Jan 2020 16:00:03 +0100 Subject: [PATCH] Mark Style::* functions `const` --- src/style.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/style.rs b/src/style.rs index 725cf4e9..6476a920 100644 --- a/src/style.rs +++ b/src/style.rs @@ -114,30 +114,33 @@ pub struct Style { impl Default for Style { fn default() -> Style { + Style::new() + } +} + +impl Style { + pub const fn new() -> Self { Style { fg: Color::Reset, bg: Color::Reset, modifier: Modifier::empty(), } } -} - -impl Style { pub fn reset(&mut self) { self.fg = Color::Reset; self.bg = Color::Reset; self.modifier = Modifier::empty(); } - pub fn fg(mut self, color: Color) -> Style { + pub const fn fg(mut self, color: Color) -> Style { self.fg = color; self } - pub fn bg(mut self, color: Color) -> Style { + pub const fn bg(mut self, color: Color) -> Style { self.bg = color; self } - pub fn modifier(mut self, modifier: Modifier) -> Style { + pub const fn modifier(mut self, modifier: Modifier) -> Style { self.modifier = modifier; self }