6 releases (2 stable)

1.1.0 Nov 11, 2023
1.0.0 Nov 11, 2023
0.12.0 Jan 18, 2023
0.11.3 Mar 15, 2021
0.11.0 Jun 4, 2020

#89 in Date and time

Download history 255/week @ 2023-12-07 398/week @ 2023-12-14 357/week @ 2023-12-21 170/week @ 2023-12-28 237/week @ 2024-01-04 402/week @ 2024-01-11 400/week @ 2024-01-18 224/week @ 2024-01-25 165/week @ 2024-02-01 318/week @ 2024-02-08 485/week @ 2024-02-15 353/week @ 2024-02-22 395/week @ 2024-02-29 546/week @ 2024-03-07 459/week @ 2024-03-14 397/week @ 2024-03-21

1,875 downloads per month

MIT/Apache

9KB
102 lines

Rusty Time

A simple timer. See also the reference docs on docs.rs

Quick Start

Add rusty_timer to your Cargo.toml with:

cargo add rusty_timer

Then use it like this:

fn main() {
    let mut timer = Timer::new(Duration::from_secs_f32(1.5));

    let mut start_time = Instant::now();
    loop {
        timer.tick(start_time.elapsed());
        start_time = Instant::now();
        println!(
            "Time on timer: {:.2}s ({:.1}%)",
            timer.remaining().as_secs_f32(),
            timer.percent_left() * 100.0
        );
        if timer.just_finished() {
            break;
        }
    }
    println!("Timer finished!");
}

Contribution

All contributions are assumed to be dual-licensed under MIT/Apache-2.

License

Distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See license/APACHE and license/MIT.

Sponsor

If you like rusty_time, please consider sponsoring me on GitHub. 💖

No runtime deps