mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 21:29:18 +00:00
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:
parent
c5898ac6b7
commit
c4708bf565
@ -29,7 +29,7 @@ pub fn verify<'a>(
|
|||||||
if !compile_result.unwrap_or(false) {
|
if !compile_result.unwrap_or(false) {
|
||||||
return Err(exercise);
|
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.set_message(format!("({:.1} %)", percentage));
|
||||||
bar.inc(1);
|
bar.inc(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user