diff options
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/display.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs index c395057a7..722092de9 100644 --- a/crates/ra_ide/src/display.rs +++ b/crates/ra_ide/src/display.rs | |||
@@ -6,12 +6,13 @@ mod navigation_target; | |||
6 | mod structure; | 6 | mod structure; |
7 | mod short_label; | 7 | mod short_label; |
8 | 8 | ||
9 | use std::fmt::{Display, Write}; | 9 | use std::fmt::Display; |
10 | 10 | ||
11 | use ra_syntax::{ | 11 | use ra_syntax::{ |
12 | ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner}, | 12 | ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner}, |
13 | SyntaxKind::{ATTR, COMMENT}, | 13 | SyntaxKind::{ATTR, COMMENT}, |
14 | }; | 14 | }; |
15 | use stdx::format_to; | ||
15 | 16 | ||
16 | pub use function_signature::FunctionSignature; | 17 | pub use function_signature::FunctionSignature; |
17 | pub use navigation_target::NavigationTarget; | 18 | pub use navigation_target::NavigationTarget; |
@@ -78,18 +79,18 @@ pub(crate) fn rust_code_markup_with_doc( | |||
78 | doc: Option<&str>, | 79 | doc: Option<&str>, |
79 | mod_path: Option<&str>, | 80 | mod_path: Option<&str>, |
80 | ) -> String { | 81 | ) -> String { |
81 | let mut markup = "```rust\n".to_owned(); | 82 | let mut buf = "```rust\n".to_owned(); |
82 | 83 | ||
83 | if let Some(mod_path) = mod_path { | 84 | if let Some(mod_path) = mod_path { |
84 | if !mod_path.is_empty() { | 85 | if !mod_path.is_empty() { |
85 | write!(markup, "{}\n", mod_path).unwrap(); | 86 | format_to!(buf, "{}\n", mod_path); |
86 | } | 87 | } |
87 | } | 88 | } |
88 | write!(markup, "{}\n```", code).unwrap(); | 89 | format_to!(buf, "{}\n```", code); |
89 | 90 | ||
90 | if let Some(doc) = doc { | 91 | if let Some(doc) = doc { |
91 | write!(markup, "\n\n{}", doc).unwrap(); | 92 | format_to!(buf, "\n\n{}", doc); |
92 | } | 93 | } |
93 | 94 | ||
94 | markup | 95 | buf |
95 | } | 96 | } |