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() {
6767 std:: process:: exit ( 1 ) ;
6868 } ) ;
6969
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+ } ) ;
7881
7982 run ( & exercise) . unwrap_or_else ( |_| std:: process:: exit ( 1 ) ) ;
8083 }
You can’t perform that action at this time.
0 commit comments