nushell/crates/nu-system/src
Devyn Cairns 13160b3ec3
Replace subtraction of Instants and Durations with saturating subtractions (#12549)
# Description
Duration can not be negative, and an underflow causes a panic.

This should fix #12539 as from what I can tell that bug was caused in
`nu-explore:📟:events` from subtracting durations, but I figured
this might be more widespread, and saturating to zero generally makes
sense.

I also added the relevant clippy lint to try to prevent this from
happening in the future. I can't think of a reason we would ever want to
subtract durations without checking first.

cc @fdncred

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
2024-04-17 07:25:16 -05:00
..
foreground.rs Local socket mode and foreground terminal control for plugins (#12448) 2024-04-15 18:28:18 +00:00
lib.rs Local socket mode and foreground terminal control for plugins (#12448) 2024-04-15 18:28:18 +00:00
linux.rs Replace subtraction of Instants and Durations with saturating subtractions (#12549) 2024-04-17 07:25:16 -05:00
macos.rs Replace subtraction of Instants and Durations with saturating subtractions (#12549) 2024-04-17 07:25:16 -05:00
os_info.rs Bump sysinfo from 0.29 to 0.30 (#11484) 2024-01-05 05:31:29 -06:00
windows.rs Replace subtraction of Instants and Durations with saturating subtractions (#12549) 2024-04-17 07:25:16 -05:00