mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-24 13:47:38 +00:00
Add some documentation for segment
This commit is contained in:
parent
9d4492c313
commit
240fb6a02c
@ -5,11 +5,12 @@ pub struct Segment {
|
|||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
style: Style,
|
style: Style,
|
||||||
value: String,
|
value: String,
|
||||||
prefix: OptionalSegment,
|
prefix: BoxedSegment,
|
||||||
suffix: OptionalSegment,
|
suffix: BoxedSegment,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Segment {
|
impl Segment {
|
||||||
|
/// Creates a new segment with default fields
|
||||||
pub fn new<T>(name: T) -> Segment
|
pub fn new<T>(name: T) -> Segment
|
||||||
where
|
where
|
||||||
T: Into<String>,
|
T: Into<String>,
|
||||||
@ -40,6 +41,9 @@ impl Segment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the style of the segment
|
||||||
|
///
|
||||||
|
/// Accepts either `Color` or `Style`.
|
||||||
pub fn set_style<T>(&mut self, style: T) -> &mut Segment
|
pub fn set_style<T>(&mut self, style: T) -> &mut Segment
|
||||||
where
|
where
|
||||||
T: Into<Style>,
|
T: Into<Style>,
|
||||||
@ -48,6 +52,7 @@ impl Segment {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the value of the segment
|
||||||
pub fn set_value<T>(&mut self, value: T) -> &mut Segment
|
pub fn set_value<T>(&mut self, value: T) -> &mut Segment
|
||||||
where
|
where
|
||||||
T: Into<String>,
|
T: Into<String>,
|
||||||
@ -56,12 +61,14 @@ impl Segment {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_prefix(&mut self, prefix: OptionalSegment) -> &mut Segment {
|
/// Sets the prefix of the segment
|
||||||
|
pub fn set_prefix(&mut self, prefix: BoxedSegment) -> &mut Segment {
|
||||||
self.prefix = prefix;
|
self.prefix = prefix;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_suffix(&mut self, suffix: OptionalSegment) -> &mut Segment {
|
/// Sets the suffix of the segment
|
||||||
|
pub fn set_suffix(&mut self, suffix: BoxedSegment) -> &mut Segment {
|
||||||
self.suffix = suffix;
|
self.suffix = suffix;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@ -69,7 +76,7 @@ impl Segment {
|
|||||||
/// Create a string with the formatted contents of a segment
|
/// Create a string with the formatted contents of a segment
|
||||||
///
|
///
|
||||||
/// Will recursively also format the prefix and suffix of the segment being
|
/// Will recursively also format the prefix and suffix of the segment being
|
||||||
/// stringified.
|
/// stringified. Skips the prefix of the first segment.
|
||||||
pub fn output(&self, index: usize) -> String {
|
pub fn output(&self, index: usize) -> String {
|
||||||
let Segment {
|
let Segment {
|
||||||
name: _name,
|
name: _name,
|
||||||
@ -98,4 +105,4 @@ impl Segment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type OptionalSegment = Option<Box<Segment>>;
|
type BoxedSegment = Option<Box<Segment>>;
|
||||||
|
Loading…
Reference in New Issue
Block a user