File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change 1
1
//! Transforms markdown
2
- use std:: borrow:: Cow ;
3
-
4
2
use ide_db:: helpers:: rust_doc:: is_rust_fence;
5
3
6
4
const RUSTDOC_FENCE : & str = "```" ;
@@ -10,9 +8,8 @@ pub(crate) fn format_docs(src: &str) -> String {
10
8
let mut in_code_block = false ;
11
9
let mut is_rust = false ;
12
10
13
- for line in src. lines ( ) {
14
- let mut line = Cow :: from ( line) ;
15
- if in_code_block && is_rust && code_line_ignored_by_rustdoc ( & line) {
11
+ for mut line in src. lines ( ) {
12
+ if in_code_block && is_rust && code_line_ignored_by_rustdoc ( line) {
16
13
continue ;
17
14
}
18
15
@@ -23,15 +20,15 @@ pub(crate) fn format_docs(src: &str) -> String {
23
20
is_rust = is_rust_fence ( header) ;
24
21
25
22
if is_rust {
26
- line = Cow :: Borrowed ( "```rust" ) ;
23
+ line = "```rust" ;
27
24
}
28
25
}
29
26
}
30
27
31
28
if in_code_block {
32
- let trimmed = line. trim ( ) ;
29
+ let trimmed = line. trim_start ( ) ;
33
30
if trimmed. starts_with ( "##" ) {
34
- line = Cow :: Owned ( line . replacen ( "##" , "#" , 1 ) ) ;
31
+ line = & trimmed [ 1 .. ] ;
35
32
}
36
33
}
37
34
You can’t perform that action at this time.
0 commit comments