summaryrefslogtreecommitdiff
path: root/src/app_state.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-30 01:39:31 +0200
committermo8it <mo8it@proton.me>2024-04-30 01:39:31 +0200
commitfef66b80ad0b90d7bbc6ebe704f34816a4b3173a (patch)
treec08b4c9a02b5f1e2c9d2b1f118a2debcd89050d1 /src/app_state.rs
parentb6f40f2ec86abc70e7b8548996c948f6c5563f46 (diff)
Implement From<ExerciseInfo> for Exercise
Diffstat (limited to 'src/app_state.rs')
-rw-r--r--src/app_state.rs27
1 files changed, 1 insertions, 26 deletions
diff --git a/src/app_state.rs b/src/app_state.rs
index 9d12c93..6af1043 100644
--- a/src/app_state.rs
+++ b/src/app_state.rs
@@ -121,34 +121,9 @@ impl AppState {
)?
.target_directory;
- // Build exercises from their metadata in the info file.
let exercises = exercise_infos
.into_iter()
- .map(|mut 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();
-
- exercise_info.name.shrink_to_fit();
- let name = exercise_info.name.leak();
- let dir = exercise_info.dir.map(|mut dir| {
- dir.shrink_to_fit();
- &*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,
- done: false,
- }
- })
+ .map(Exercise::from)
.collect::<Vec<_>>();
let mut slf = Self {