@@ -83,12 +83,6 @@ impl AppState {
8383 let mut exercises = exercise_infos
8484 . into_iter ( )
8585 . map ( |exercise_info| {
86- // Leaking to be able to borrow in the watch mode `Table`.
87- // Leaking is not a problem because the `AppState` instance lives until
88- // the end of the program.
89- let path = exercise_info. path ( ) . leak ( ) ;
90- let hint = exercise_info. hint . trim_ascii ( ) ;
91-
9286 let canonical_path = dir_canonical_path. as_deref ( ) . map ( |dir_canonical_path| {
9387 let mut canonical_path;
9488 if let Some ( dir) = exercise_info. dir {
@@ -114,11 +108,11 @@ impl AppState {
114108 Exercise {
115109 dir : exercise_info. dir ,
116110 name : exercise_info. name ,
117- path,
111+ path : exercise_info . path ( ) ,
118112 canonical_path,
119113 test : exercise_info. test ,
120114 strict_clippy : exercise_info. strict_clippy ,
121- hint,
115+ hint : exercise_info . hint . trim_ascii ( ) ,
122116 // Updated below.
123117 done : false ,
124118 }
@@ -342,12 +336,12 @@ impl AppState {
342336 Ok ( ( ) )
343337 }
344338
345- pub fn reset_current_exercise ( & mut self ) -> Result < & ' static str > {
339+ pub fn reset_current_exercise ( & mut self ) -> Result < & str > {
346340 self . set_pending ( self . current_exercise_ind ) ?;
347341 let exercise = self . current_exercise ( ) ;
348- self . reset ( self . current_exercise_ind , exercise. path ) ?;
342+ self . reset ( self . current_exercise_ind , & exercise. path ) ?;
349343
350- Ok ( exercise. path )
344+ Ok ( & exercise. path )
351345 }
352346
353347 // Reset the exercise by index and return its name.
@@ -358,7 +352,7 @@ impl AppState {
358352
359353 self . set_pending ( exercise_ind) ?;
360354 let exercise = & self . exercises [ exercise_ind] ;
361- self . reset ( exercise_ind, exercise. path ) ?;
355+ self . reset ( exercise_ind, & exercise. path ) ?;
362356
363357 Ok ( exercise. name )
364358 }
@@ -600,7 +594,7 @@ mod tests {
600594 Exercise {
601595 dir : None ,
602596 name : "0" ,
603- path : "exercises/0.rs" ,
597+ path : String :: from ( "exercises/0.rs" ) ,
604598 canonical_path : None ,
605599 test : false ,
606600 strict_clippy : false ,
0 commit comments