mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-06-19 22:58:50 +02:00
Avoid unneeded computation on full progress bar
This commit is contained in:
+6
-7
@@ -227,14 +227,13 @@ pub fn progress_bar<'a>(
|
||||
|
||||
if filled < width {
|
||||
stdout.write_all(b">")?;
|
||||
}
|
||||
|
||||
let width_minus_filled = width - filled;
|
||||
if width_minus_filled > 1 {
|
||||
let red_part_width = width_minus_filled - 1;
|
||||
stdout.queue(SetForegroundColor(Color::Red))?;
|
||||
for _ in 0..red_part_width {
|
||||
stdout.write_all(b"-")?;
|
||||
let width_minus_filled = width - filled;
|
||||
if width_minus_filled > 1 {
|
||||
stdout.queue(SetForegroundColor(Color::Red))?;
|
||||
for _ in 1..width_minus_filled {
|
||||
stdout.write_all(b"-")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user