File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -91,23 +91,22 @@ fn main() {
91
91
println ! ( "\n {WELCOME}\n " ) ;
92
92
}
93
93
94
- if !Path :: new ( "info.toml" ) . exists ( ) {
95
- println ! (
96
- "{} must be run from the rustlings directory" ,
97
- std:: env:: current_exe( ) . unwrap( ) . to_str( ) . unwrap( )
98
- ) ;
99
- println ! ( "Try `cd rustlings/`!" ) ;
100
- std:: process:: exit ( 1 ) ;
101
- }
102
-
103
94
if !rustc_exists ( ) {
104
95
println ! ( "We cannot find `rustc`." ) ;
105
96
println ! ( "Try running `rustc --version` to diagnose your problem." ) ;
106
97
println ! ( "For instructions on how to install Rust, check the README." ) ;
107
98
std:: process:: exit ( 1 ) ;
108
99
}
109
100
110
- let info_file = fs:: read_to_string ( "info.toml" ) . unwrap ( ) ;
101
+ let info_file = fs:: read_to_string ( "info.toml" ) . unwrap_or_else ( |e| {
102
+ match e. kind ( ) {
103
+ io:: ErrorKind :: NotFound => println ! (
104
+ "The program must be run from the rustlings directory\n Try `cd rustlings/`!" ,
105
+ ) ,
106
+ _ => println ! ( "Failed to read the info.toml file: {e}" ) ,
107
+ }
108
+ std:: process:: exit ( 1 ) ;
109
+ } ) ;
111
110
let exercises = toml_edit:: de:: from_str :: < ExerciseList > ( & info_file)
112
111
. unwrap ( )
113
112
. exercises ;
You can’t perform that action at this time.
0 commit comments