diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-09 09:34:12 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-09 09:34:12 +0100 |
commit | 9eb9b9df9f6adebb938029a86e47c0aa1eb0f678 (patch) | |
tree | f9ca6a356d794239434a7ef1c9a8ba749834c5f6 /crates/ra_ide/src/markup.rs | |
parent | a61c8481571f8d8e6e08df9024d8dad5efc883de (diff) | |
parent | b9aab22d569c4ffe4d4f544a778bf07441ccf118 (diff) |
Merge #5276
5276: Streamline r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/markup.rs')
-rw-r--r-- | crates/ra_ide/src/markup.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_ide/src/markup.rs b/crates/ra_ide/src/markup.rs index 2f2b3cc25..60c193c40 100644 --- a/crates/ra_ide/src/markup.rs +++ b/crates/ra_ide/src/markup.rs | |||
@@ -16,6 +16,12 @@ impl From<Markup> for String { | |||
16 | } | 16 | } |
17 | } | 17 | } |
18 | 18 | ||
19 | impl From<String> for Markup { | ||
20 | fn from(text: String) -> Self { | ||
21 | Markup { text } | ||
22 | } | ||
23 | } | ||
24 | |||
19 | impl fmt::Display for Markup { | 25 | impl fmt::Display for Markup { |
20 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | 26 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
21 | fmt::Display::fmt(&self.text, f) | 27 | fmt::Display::fmt(&self.text, f) |
@@ -26,13 +32,7 @@ impl Markup { | |||
26 | pub fn as_str(&self) -> &str { | 32 | pub fn as_str(&self) -> &str { |
27 | self.text.as_str() | 33 | self.text.as_str() |
28 | } | 34 | } |
29 | pub fn is_empty(&self) -> bool { | 35 | pub fn fenced_block(contents: &impl fmt::Display) -> Markup { |
30 | self.text.is_empty() | 36 | format!("```rust\n{}\n```", contents).into() |
31 | } | ||
32 | pub fn push_section(&mut self, section: &str) { | ||
33 | if !self.text.is_empty() { | ||
34 | self.text.push_str("\n\n___\n"); | ||
35 | } | ||
36 | self.text.push_str(section); | ||
37 | } | 37 | } |
38 | } | 38 | } |