diff options
author | Gokul Soumya | 2022-07-08 18:46:09 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2023-01-18 05:19:32 +0000 |
commit | 9aafcb2b9a743f0f6afa722184e96b8a672064ea (patch) | |
tree | 83a02218ee16dbcd14ce05a4628713396a3aaf52 /helix-tui/src/text.rs | |
parent | deae13f404fadddf16f7c2005af8b383a1d8e362 (diff) |
Reuse table in picker
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>; |