Document exercise

This commit is contained in:
mo8it
2024-05-13 21:36:20 +02:00
parent 2dfc7cdb1a
commit 39a19f9450
2 changed files with 36 additions and 35 deletions
+21 -1
View File
@@ -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 {