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() {
9191 println ! ( "\n {WELCOME}\n " ) ;
9292 }
9393
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-
10394 if !rustc_exists ( ) {
10495 println ! ( "We cannot find `rustc`." ) ;
10596 println ! ( "Try running `rustc --version` to diagnose your problem." ) ;
10697 println ! ( "For instructions on how to install Rust, check the README." ) ;
10798 std:: process:: exit ( 1 ) ;
10899 }
109100
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+ } ) ;
111110 let exercises = toml_edit:: de:: from_str :: < ExerciseList > ( & info_file)
112111 . unwrap ( )
113112 . exercises ;
You can’t perform that action at this time.
0 commit comments