mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-27 00:00:03 +03:00
Verify starting with some index
This commit is contained in:
parent
c2daad8340
commit
18342b3aa3
|
@ -14,17 +14,16 @@ pub enum VerifyState<'a> {
|
||||||
// Any such failures will be reported to the end user.
|
// Any such failures will be reported to the end user.
|
||||||
// If the Exercise being verified is a test, the verbose boolean
|
// If the Exercise being verified is a test, the verbose boolean
|
||||||
// determines whether or not the test harness outputs are displayed.
|
// determines whether or not the test harness outputs are displayed.
|
||||||
pub fn verify<'a>(
|
pub fn verify(exercises: &[Exercise], mut current_exercise_ind: usize) -> Result<VerifyState<'_>> {
|
||||||
pending_exercises: impl IntoIterator<Item = &'a Exercise>,
|
while current_exercise_ind < exercises.len() {
|
||||||
progress: (usize, usize),
|
let exercise = &exercises[current_exercise_ind];
|
||||||
) -> Result<VerifyState<'a>> {
|
|
||||||
let (mut num_done, total) = progress;
|
println!(
|
||||||
println!(
|
"Progress: {current_exercise_ind}/{} ({:.1}%)\n",
|
||||||
"Progress: {num_done}/{total} ({:.1}%)\n",
|
exercises.len(),
|
||||||
num_done as f32 / total as f32 * 100.0,
|
current_exercise_ind as f32 / exercises.len() as f32 * 100.0,
|
||||||
);
|
);
|
||||||
|
|
||||||
for exercise in pending_exercises {
|
|
||||||
let output = exercise.run()?;
|
let output = exercise.run()?;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -76,11 +75,7 @@ or jump into the next one by removing the {} comment:\n",
|
||||||
return Ok(VerifyState::Failed(exercise));
|
return Ok(VerifyState::Failed(exercise));
|
||||||
}
|
}
|
||||||
|
|
||||||
num_done += 1;
|
current_exercise_ind += 1;
|
||||||
println!(
|
|
||||||
"Progress: {num_done}/{total} ({:.1}%)\n",
|
|
||||||
num_done as f32 / total as f32 * 100.0,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(VerifyState::AllExercisesDone)
|
Ok(VerifyState::AllExercisesDone)
|
||||||
|
|
Loading…
Reference in a new issue