use animate::animate;
use std::{
io::{Write, stdout},
thread,
time::Duration,
};
#[animate]
struct Counter {
#[once(duration = 400)]
value: u32,
}
fn main() -> std::io::Result<()> {
let mut c = Counter::new(0);
loop {
animate::tick();
let v = *c.value;
if v == 0 {
c.value.set(100);
}
print!("\rCounter value: {v}");
stdout().flush()?;
if v == 100 {
break;
}
thread::sleep(Duration::from_millis(8));
}
Ok(())
}