diff options
| author | mo8it <mo8it@proton.me> | 2024-04-07 01:16:56 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-07 01:16:56 +0200 |
| commit | 18342b3aa3bd43c2c013614935f45e7d6bbaea8f (patch) | |
| tree | 367b43eb79a7ed71f2648607c3c9f4dac37c3095 | |
| parent | c2daad8340c04eaa84525f6ee832972667068fd6 (diff) | |
Verify starting with some index
| -rw-r--r-- | src/verify.rs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/verify.rs b/src/verify.rs index aec2185..c4368cc 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -14,17 +14,16 @@ pub enum VerifyState<'a> { // Any such failures will be reported to the end user. // If the Exercise being verified is a test, the verbose boolean // determines whether or not the test harness outputs are displayed. -pub fn verify<'a>( - pending_exercises: impl IntoIterator<Item = &'a Exercise>, - progress: (usize, usize), -) -> Result<VerifyState<'a>> { - let (mut num_done, total) = progress; - println!( - "Progress: {num_done}/{total} ({:.1}%)\n", - num_done as f32 / total as f32 * 100.0, - ); +pub fn verify(exercises: &[Exercise], mut current_exercise_ind: usize) -> Result<VerifyState<'_>> { + while current_exercise_ind < exercises.len() { + let exercise = &exercises[current_exercise_ind]; + + println!( + "Progress: {current_exercise_ind}/{} ({:.1}%)\n", + exercises.len(), + current_exercise_ind as f32 / exercises.len() as f32 * 100.0, + ); - for exercise in pending_exercises { let output = exercise.run()?; { @@ -76,11 +75,7 @@ or jump into the next one by removing the {} comment:\n", return Ok(VerifyState::Failed(exercise)); } - num_done += 1; - println!( - "Progress: {num_done}/{total} ({:.1}%)\n", - num_done as f32 / total as f32 * 100.0, - ); + current_exercise_ind += 1; } Ok(VerifyState::AllExercisesDone) |
