@@ -116,7 +116,7 @@ impl Config {
116
116
}
117
117
118
118
fn get_feature ( line : & str ) -> Option < & str > {
119
- let re = Regex :: new ( "^\\ s*### .*$" ) . unwrap ( ) ;
119
+ let re = Regex :: new ( "^\\ s*### .*$" ) . expect ( "fixed regex always valid" ) ;
120
120
if re. is_match ( line) {
121
121
Some ( line. trim ( ) [ 3 ..] . trim ( ) )
122
122
} else {
@@ -244,14 +244,24 @@ pub fn template(
244
244
mode : Mode ,
245
245
ignore : Vec < & str > ,
246
246
) -> Result < ( ) , Box < dyn Error > > {
247
- for entry in WalkDir :: new ( source_dir) . into_iter ( ) . filter_entry ( |entry| {
248
- let ignore_list: Vec < & Path > = ignore. iter ( ) . map ( |fname| Path :: new ( fname) ) . collect ( ) ;
249
-
250
- !ignore_list. contains ( & entry. path ( ) . strip_prefix ( & source_dir) . unwrap ( ) )
251
- } ) {
247
+ let ignore_list: Vec < & Path > = ignore. iter ( ) . map ( |fname| Path :: new ( fname) ) . collect ( ) ;
248
+
249
+ let filtered_paths = WalkDir :: new ( source_dir) . into_iter ( ) . filter_entry ( |entry| {
250
+ !ignore_list. contains (
251
+ & entry
252
+ . path ( )
253
+ . strip_prefix ( & source_dir)
254
+ . expect ( "entry should always have source_dir prefix" ) ,
255
+ )
256
+ } ) ;
257
+
258
+ for entry in filtered_paths {
252
259
let source_file = entry?;
253
260
let source_file = source_file. path ( ) ;
254
- let dest_file = source_file. to_str ( ) . unwrap ( ) . replace ( source_dir, dest_dir) ;
261
+ let dest_file = source_file
262
+ . to_str ( )
263
+ . expect ( "expected UTF-8 path" )
264
+ . replace ( source_dir, dest_dir) ;
255
265
let dest_file = Path :: new ( & dest_file) ;
256
266
257
267
match mode {
0 commit comments