bevy/crates/bevy_time
Lucas af93e78b72
Fix overflow panic on Stopwatch at Duration::MAX (#15927)
See #15924 for more details
close #15924

from the issue, this code panic:
```rust
use bevy::time::Stopwatch;
use std::time::Duration;

fn main() {
    let second = Duration::from_secs(1);

    let mut stopwatch = Stopwatch::new();
    // lot of time has passed... or a timer with Duration::MAX that was artificially set has "finished":
    // timer.set_elapsed(timer.remaining());
    stopwatch.set_elapsed(Duration::MAX);
    // panic
    stopwatch.tick(second);

    let mut stopwatch = Stopwatch::new();
    stopwatch.set_elapsed(Duration::MAX - second);
    // this doesnt panic as its still one off the max
    stopwatch.tick(second);
    // this panic
    stopwatch.tick(second);
}
```

with this PR changes, the code now doesn't panic.

have a good day !
2024-10-15 14:14:44 +00:00
..
src Fix overflow panic on Stopwatch at Duration::MAX (#15927) 2024-10-15 14:14:44 +00:00
Cargo.toml Remove thiserror from bevy_time (#15759) 2024-10-09 14:13:28 +00:00
README.md Add README.md to all crates (#13184) 2024-05-02 18:56:00 +00:00

Bevy Time

License Crates.io Downloads Docs Discord

The built-in timekeeping plugin for the Bevy game engine.