diff options
Diffstat (limited to 'src/segment.rs')
-rw-r--r-- | src/segment.rs | 48 |
1 files changed, 6 insertions, 42 deletions
diff --git a/src/segment.rs b/src/segment.rs index 13f527083..200a93b9e 100644 --- a/src/segment.rs +++ b/src/segment.rs @@ -6,9 +6,6 @@ use std::fmt; /// (e.g. The version that software is running). #[derive(Clone)] pub struct Segment { - /// The segment's name, to be used in configuration and logging. - pub _name: String, - /// The segment's style. If None, will inherit the style of the module containing it. pub style: Option<Style>, @@ -17,43 +14,15 @@ pub struct Segment { } impl Segment { - /// Creates a new segment with default fields. - pub fn new(name: &str) -> Self { - Self { - _name: name.to_string(), - style: None, - value: "".to_string(), - } - } - - /// Sets the style of the segment. - /// - /// Accepts either `Color` or `Style`. - pub fn set_style<T>(&mut self, style: T) -> &mut Self - where - T: Into<Style>, - { - self.style = Some(style.into()); - self - } - - /// Check if the segment has a style - pub fn has_style(&self) -> bool { - self.style.is_some() - } - - /// Sets the value of the segment. - pub fn set_value<T>(&mut self, value: T) -> &mut Self + /// Creates a new segment. + pub fn new<T>(style: Option<Style>, value: T) -> Self where T: Into<String>, { - self.value = value.into(); - self - } - - /// Gets the value of the segment. - pub fn get_value(&self) -> &str { - &self.value + Self { + style, + value: value.into(), + } } // Returns the ANSIString of the segment value, not including its prefix and suffix @@ -63,11 +32,6 @@ impl Segment { None => ANSIString::from(&self.value), } } - - /// Determines if the segment contains a value. - pub fn is_empty(&self) -> bool { - self.value.trim().is_empty() - } } impl fmt::Display for Segment { |