bevy/crates/bevy_time/src
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
..
common_conditions.rs Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
fixed.rs Allow ordering variable timesteps around fixed timesteps (#14881) 2024-08-23 16:19:42 +00:00
lib.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
real.rs Time<Real> documentation improvement (#15874) 2024-10-13 17:26:40 +00:00
stopwatch.rs Fix overflow panic on Stopwatch at Duration::MAX (#15927) 2024-10-15 14:14:44 +00:00
time.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
timer.rs Adds doc note that Timer and Stopwatch must be progressed manually (#13441) 2024-05-20 19:46:25 +00:00
virt.rs Make bevy_time optionally depend on bevy_reflect (#13263) 2024-05-12 23:19:07 +00:00