File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 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> {
142142 match lines. next ( ) {
143143 Some ( ( lineno, line) ) => {
144144 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 ( ) ) ;
147147 } else if line. starts_with ( "///" ) {
148148 doc_lines. push ( "" . to_string ( ) ) ;
149149 } else if line. starts_with ( "// " ) {
@@ -347,8 +347,7 @@ impl<'a> LintExtractor<'a> {
347347 let mut source = String :: new ( ) ;
348348 let needs_main = !example. iter ( ) . any ( |line| line. contains ( "fn main" ) ) ;
349349 // 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) ) ;
352351 let mut lines = unhidden. peekable ( ) ;
353352 while let Some ( line) = lines. peek ( ) {
354353 if line. starts_with ( "#!" ) {
You can’t perform that action at this time.
0 commit comments