diff options
Diffstat (limited to 'helix-tui/src/text.rs')
-rw-r--r-- | helix-tui/src/text.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/helix-tui/src/text.rs b/helix-tui/src/text.rs index ccdafad5..6970634b 100644 --- a/helix-tui/src/text.rs +++ b/helix-tui/src/text.rs @@ -436,6 +436,19 @@ impl<'a> From<Vec<Spans<'a>>> for Text<'a> { } } +impl<'a> From<Text<'a>> for String { + fn from(text: Text<'a>) -> String { + let lines: Vec<String> = text.lines.iter().map(String::from).collect(); + lines.join("\n") + } +} + +impl<'a> From<&Text<'a>> for String { + fn from(text: &Text<'a>) -> String { + let lines: Vec<String> = text.lines.iter().map(String::from).collect(); + lines.join("\n") + } +} impl<'a> IntoIterator for Text<'a> { type Item = Spans<'a>; type IntoIter = std::vec::IntoIter<Self::Item>; |