From f0af4ddc40ee1c1cca749a01423bfe4ec60300fe Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 7 Jul 2022 16:17:12 +0200 Subject: [PATCH] Expose chunks and chunk contents --- src/styled.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/styled.rs b/src/styled.rs index 2ee4efb..1a19540 100644 --- a/src/styled.rs +++ b/src/styled.rs @@ -15,6 +15,14 @@ impl Chunk { } } + pub fn string(&self) -> &str { + &self.string + } + + pub fn style(&self) -> ContentStyle { + self.style + } + pub fn plain(string: S) -> Self { Self::new(string, ContentStyle::default()) } @@ -81,6 +89,10 @@ impl Styled { self } + pub fn chunks(&self) -> &[Chunk] { + &self.0 + } + pub fn text(&self) -> String { self.0.iter().flat_map(|c| c.string.chars()).collect() }