fix bug when showing percentage

num_done here will alaways be zero, so the percentage here will always be 0%.
fix bug by using bar.position() instead of num_done so that we can get the right percentage .
This commit is contained in:
focksor surooi 2023-01-10 20:44:12 +08:00 committed by GitHub
parent c5898ac6b7
commit c4708bf565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,7 @@ pub fn verify<'a>(
if !compile_result.unwrap_or(false) {
return Err(exercise);
}
let percentage = num_done as f32 / total as f32 * 100.0;
let percentage = bar.position() as f32 / total as f32 * 100.0;
bar.set_message(format!("({:.1} %)", percentage));
bar.inc(1);
}