Expose chunks and chunk contents

This commit is contained in:
Joscha 2022-07-07 16:17:12 +02:00
parent 26bf89023e
commit f0af4ddc40

View file

@ -15,6 +15,14 @@ impl Chunk {
} }
} }
pub fn string(&self) -> &str {
&self.string
}
pub fn style(&self) -> ContentStyle {
self.style
}
pub fn plain<S: ToString>(string: S) -> Self { pub fn plain<S: ToString>(string: S) -> Self {
Self::new(string, ContentStyle::default()) Self::new(string, ContentStyle::default())
} }
@ -81,6 +89,10 @@ impl Styled {
self self
} }
pub fn chunks(&self) -> &[Chunk] {
&self.0
}
pub fn text(&self) -> String { pub fn text(&self) -> String {
self.0.iter().flat_map(|c| c.string.chars()).collect() self.0.iter().flat_map(|c| c.string.chars()).collect()
} }