diff options
| author | mo8it <mo8it@proton.me> | 2024-05-13 21:36:20 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-05-13 21:36:20 +0200 |
| commit | 39a19f945008ef59af107fe54d9dc62943469c8b (patch) | |
| tree | 1a6d18cb794f07fe11f947b8286a5283fa6a76ce /src/app_state.rs | |
| parent | 2dfc7cdb1a26f46c5537e10e8a182dd2125758cb (diff) | |
Document exercise
Diffstat (limited to 'src/app_state.rs')
| -rw-r--r-- | src/app_state.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/app_state.rs b/src/app_state.rs index 75014ce..b10ebb5 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -124,7 +124,27 @@ impl AppState { let exercises = exercise_infos .into_iter() - .map(Exercise::from) + .map(|exercise_info| { + // Leaking to be able to borrow in the watch mode `Table`. + // Leaking is not a problem because the `AppState` instance lives until + // the end of the program. + let path = exercise_info.path().leak(); + let name = exercise_info.name.leak(); + let dir = exercise_info.dir.map(|dir| &*dir.leak()); + + let hint = exercise_info.hint.trim().to_owned(); + + Exercise { + dir, + name, + path, + test: exercise_info.test, + strict_clippy: exercise_info.strict_clippy, + hint, + // Updated in `Self::update_from_file`. + done: false, + } + }) .collect::<Vec<_>>(); let mut slf = Self { |
