From f40f73dc8e26e6d8730344f4c6cbb47ee3d48342 Mon Sep 17 00:00:00 2001 From: Matan Kushner Date: Wed, 31 Jul 2019 19:48:51 -0400 Subject: fix: Address longstanding linter errors --- src/module.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/module.rs') diff --git a/src/module.rs b/src/module.rs index 526345b95..ade5d9e5d 100644 --- a/src/module.rs +++ b/src/module.rs @@ -17,13 +17,13 @@ pub struct Module<'a> { style: Style, /// The prefix used to separate the current module from the previous one. - prefix: ModuleAffix, + prefix: Affix, /// The collection of segments that compose this module. segments: Vec, /// The suffix used to separate the current module from the next one. - suffix: ModuleAffix, + suffix: Affix, } impl<'a> Module<'a> { @@ -33,9 +33,9 @@ impl<'a> Module<'a> { config, name: name.to_string(), style: Style::default(), - prefix: ModuleAffix::default_prefix(name.to_string()), + prefix: Affix::default_prefix(name), segments: Vec::new(), - suffix: ModuleAffix::default_suffix(name.to_string()), + suffix: Affix::default_suffix(name), } } @@ -56,12 +56,12 @@ impl<'a> Module<'a> { } /// Get the module's prefix - pub fn get_prefix(&mut self) -> &mut ModuleAffix { + pub fn get_prefix(&mut self) -> &mut Affix { &mut self.prefix } /// Get the module's suffix - pub fn get_suffix(&mut self) -> &mut ModuleAffix { + pub fn get_suffix(&mut self) -> &mut Affix { &mut self.suffix } @@ -82,7 +82,7 @@ impl<'a> Module<'a> { let mut ansi_strings = self .segments .iter() - .map(|s| s.ansi_string()) + .map(Segment::ansi_string) .collect::>(); ansi_strings.insert(0, self.prefix.ansi_string()); @@ -119,7 +119,7 @@ impl<'a> fmt::Display for Module<'a> { } /// Module affixes are to be used for the prefix or suffix of a module. -pub struct ModuleAffix { +pub struct Affix { /// The affix's name, to be used in configuration and logging. name: String, @@ -130,17 +130,17 @@ pub struct ModuleAffix { value: String, } -impl ModuleAffix { - pub fn default_prefix(name: String) -> ModuleAffix { - ModuleAffix { +impl Affix { + pub fn default_prefix(name: &str) -> Self { + Self { name: format!("{}_prefix", name), style: Style::default(), value: "via ".to_string(), } } - pub fn default_suffix(name: String) -> ModuleAffix { - ModuleAffix { + pub fn default_suffix(name: &str) -> Self { + Self { name: format!("{}_suffix", name), style: Style::default(), value: " ".to_string(), @@ -150,7 +150,7 @@ impl ModuleAffix { /// Sets the style of the module. /// /// Accepts either `Color` or `Style`. - pub fn set_style(&mut self, style: T) -> &mut ModuleAffix + pub fn set_style(&mut self, style: T) -> &mut Self where T: Into