File tree 1 file changed +3
-4
lines changed
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -142,8 +142,8 @@ impl<'a> LintExtractor<'a> {
142
142
match lines. next ( ) {
143
143
Some ( ( lineno, line) ) => {
144
144
let line = line. trim ( ) ;
145
- if line. starts_with ( "/// " ) {
146
- doc_lines. push ( line . trim ( ) [ 4 .. ] . to_string ( ) ) ;
145
+ if let Some ( text ) = line. strip_prefix ( "/// " ) {
146
+ doc_lines. push ( text . trim ( ) . to_string ( ) ) ;
147
147
} else if line. starts_with ( "///" ) {
148
148
doc_lines. push ( "" . to_string ( ) ) ;
149
149
} else if line. starts_with ( "// " ) {
@@ -347,8 +347,7 @@ impl<'a> LintExtractor<'a> {
347
347
let mut source = String :: new ( ) ;
348
348
let needs_main = !example. iter ( ) . any ( |line| line. contains ( "fn main" ) ) ;
349
349
// Remove `# ` prefix for hidden lines.
350
- let unhidden =
351
- example. iter ( ) . map ( |line| if line. starts_with ( "# " ) { & line[ 2 ..] } else { line } ) ;
350
+ let unhidden = example. iter ( ) . map ( |line| line. strip_prefix ( "# " ) . unwrap_or ( line) ) ;
352
351
let mut lines = unhidden. peekable ( ) ;
353
352
while let Some ( line) = lines. peek ( ) {
354
353
if line. starts_with ( "#!" ) {
You can’t perform that action at this time.
0 commit comments