File tree 1 file changed +22
-21
lines changed
1 file changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ fn unindent_fragments(docs: &mut Vec<DocFragment>) {
46
46
// #[doc = "another"]
47
47
//
48
48
// In this case, you want "hello! another" and not "hello! another".
49
- let add = if ! docs. windows ( 2 ) . all ( |arr| arr[ 0 ] . kind = = arr[ 1 ] . kind )
49
+ let add = if docs. windows ( 2 ) . any ( |arr| arr[ 0 ] . kind ! = arr[ 1 ] . kind )
50
50
&& docs. iter ( ) . any ( |d| d. kind == DocFragmentKind :: SugaredDoc )
51
51
{
52
52
// In case we have a mix of sugared doc comments and "raw" ones, we want the sugared one to
@@ -87,27 +87,28 @@ fn unindent_fragments(docs: &mut Vec<DocFragment>) {
87
87
} ;
88
88
89
89
for fragment in docs {
90
- let lines: Vec < _ > = fragment. doc . lines ( ) . collect ( ) ;
90
+ if fragment. doc . lines ( ) . count ( ) == 0 {
91
+ continue ;
92
+ }
91
93
92
- if !lines. is_empty ( ) {
93
- let min_indent = if fragment. kind != DocFragmentKind :: SugaredDoc && min_indent > 0 {
94
- min_indent - add
95
- } else {
96
- min_indent
97
- } ;
94
+ let min_indent = if fragment. kind != DocFragmentKind :: SugaredDoc && min_indent > 0 {
95
+ min_indent - add
96
+ } else {
97
+ min_indent
98
+ } ;
98
99
99
- fragment. doc = lines
100
- . iter ( )
101
- . map ( | & line| {
102
- if line . chars ( ) . all ( |c| c . is_whitespace ( ) ) {
103
- line. to_string ( )
104
- } else {
105
- assert ! ( line . len ( ) >= min_indent ) ;
106
- line[ min_indent.. ] . to_string ( )
107
- }
108
- } )
109
- . collect :: < Vec < _ > > ( )
110
- . join ( " \n " ) ;
111
- }
100
+ fragment. doc = fragment
101
+ . doc
102
+ . lines ( )
103
+ . map ( |line| {
104
+ if line. chars ( ) . all ( |c| c . is_whitespace ( ) ) {
105
+ line . to_string ( )
106
+ } else {
107
+ assert ! ( line. len ( ) >= min_indent ) ;
108
+ line [ min_indent.. ] . to_string ( )
109
+ }
110
+ } )
111
+ . collect :: < Vec < _ > > ( )
112
+ . join ( " \n " ) ;
112
113
}
113
114
}
You can’t perform that action at this time.
0 commit comments