File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -67,14 +67,17 @@ fn main() {
67
67
std:: process:: exit ( 1 ) ;
68
68
} ) ;
69
69
70
- let filepath = Path :: new ( filename) . canonicalize ( ) . unwrap ( ) ;
71
- let exercise = exercises
72
- . iter ( )
73
- . find ( |e| filepath. ends_with ( & e. path ) )
74
- . unwrap_or_else ( || {
75
- println ! ( "No exercise found for your file name!" ) ;
76
- std:: process:: exit ( 1 )
77
- } ) ;
70
+ let matching_exercise = |e : & & Exercise | {
71
+ Path :: new ( filename)
72
+ . canonicalize ( )
73
+ . map ( |p| p. ends_with ( & e. path ) )
74
+ . unwrap_or ( false )
75
+ } ;
76
+
77
+ let exercise = exercises. iter ( ) . find ( matching_exercise) . unwrap_or_else ( || {
78
+ println ! ( "No exercise found for your file name!" ) ;
79
+ std:: process:: exit ( 1 )
80
+ } ) ;
78
81
79
82
run ( & exercise) . unwrap_or_else ( |_| std:: process:: exit ( 1 ) ) ;
80
83
}
You can’t perform that action at this time.
0 commit comments