macro_rules! progress {
($bar:ident, $($fmt_args:tt)*) => { ... };
($bar:ident += $inc:expr) => { ... };
($bar:ident += $inc:expr, $($fmt_args:tt)*) => { ... };
($bar:ident = $x:expr) => { ... };
($bar:ident = $x:expr, $($fmt_args:tt)*) => { ... };
}Available on crate feature
print only.Expand description
Update a progress bar
The macro takes 2 parts separated by comma ,:
- An expression for updating the progress:
- Optional format args for updating the message.
The progress update expression can be one of:
bar = i: set the progress toibar += i: increment the steps by ibar: don’t update the progress
, where bar is an ident
The format args can be omitted to update the progress without updating the message
§Examples
let bar = cu::progress("10 steps").total(10).spawn();
// update the current count and message
let i = 1;
cu::progress!(bar = i, "doing step {i}");
// update the current count without changing message
cu::progress!(bar += 2);
// update the message without changing current step
cu::progress!(bar, "doing the thing");