@@ -79,25 +79,25 @@ fn parse_priority(word: &str) -> Option<isize> {
79
79
let priority_substr = lowercase_word. split ( "todo" ) . nth ( 1 ) . unwrap ( ) ;
80
80
81
81
if priority_substr. len ( ) == 1 {
82
- return Some ( priority_substr. to_string ( ) . parse :: < isize > ( ) . unwrap ( ) ) ;
82
+ Some ( priority_substr. to_string ( ) . parse :: < isize > ( ) . unwrap ( ) )
83
83
} else if priority_substr. chars ( ) . all ( |ch| ch == '0' ) {
84
84
// todo0: 1 - 1 = 0
85
85
// todo00: 1 - 2 = -1
86
- return Some ( 1 - priority_substr. len ( ) as isize ) ;
86
+ Some ( 1 - priority_substr. len ( ) as isize )
87
87
} else {
88
- return None ; // invalid syntax like todo11
88
+ None // invalid syntax like todo11
89
89
}
90
90
}
91
91
92
92
/// Remove closing tags, comments, and whitespace
93
93
fn clean_line < ' a > ( line : & ' a str , delimiter_word : & str ) -> & ' a str {
94
- return line. split_once ( delimiter_word) . unwrap ( ) . 1
94
+ line. split_once ( delimiter_word) . unwrap ( ) . 1
95
95
. trim ( )
96
96
. trim_end_matches ( "*/" )
97
97
. trim_end_matches ( "-->" )
98
98
. trim_end_matches ( "--}}" )
99
99
. trim_end_matches ( "/>" )
100
- . trim ( ) ;
100
+ . trim ( )
101
101
}
102
102
103
103
pub fn add_excludes_from_gitignore ( base_dir : & PathBuf , excludes : & mut Vec < PathBuf > ) {
@@ -114,7 +114,7 @@ pub fn add_excludes_from_gitignore(base_dir: &PathBuf, excludes: &mut Vec<PathBu
114
114
}
115
115
116
116
if line. trim ( ) == "*" {
117
- if let Ok ( realpath) = canonicalize ( & base_dir) {
117
+ if let Ok ( realpath) = canonicalize ( base_dir) {
118
118
excludes. push ( realpath) ;
119
119
}
120
120
@@ -217,10 +217,9 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
217
217
}
218
218
219
219
pub fn scan_file ( path : & Path , entries : & mut Vec < Entry > ) -> io:: Result < ( ) > {
220
- match std:: fs:: read_to_string ( path) {
221
- Ok ( str) => scan_string ( str, path. to_path_buf ( ) , entries) ,
222
- Err ( _) => ( ) ,
223
- } ;
220
+ if let Ok ( str) = std:: fs:: read_to_string ( path) {
221
+ scan_string ( str, path. to_path_buf ( ) , entries) ;
222
+ }
224
223
225
224
Ok ( ( ) )
226
225
}
@@ -237,7 +236,7 @@ pub fn scan_dir(dir: &Path, entries: &mut Vec<Entry>, excludes: &mut Vec<PathBuf
237
236
// so the exclude would not affect anything inside the for loop. For that reason, we re-check if
238
237
// `dir` hasn't become excluded after running `add_excludes_from_gitignore`.
239
238
for exclude in & * excludes {
240
- if canonicalize ( dir. to_path_buf ( ) ) . unwrap ( ) == * exclude {
239
+ if canonicalize ( dir) . unwrap ( ) == * exclude {
241
240
return Ok ( ( ) ) ;
242
241
}
243
242
}
@@ -347,11 +346,7 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()>
347
346
let section = line. split_once ( "# " ) . unwrap ( ) . 1 ;
348
347
let cleaned_section = section. to_lowercase ( ) . trim_end_matches ( ':' ) . trim ( ) . to_string ( ) ;
349
348
350
- if cleaned_section == "todo" || cleaned_section == "todos" {
351
- in_todo_section = true ;
352
- } else {
353
- in_todo_section = false ;
354
- }
349
+ in_todo_section = cleaned_section == "todo" || cleaned_section == "todos" ;
355
350
356
351
continue ;
357
352
}
0 commit comments