nushell/crates/nu-explore/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
..
commands Reuse existing small allocations if possible (#12335) 2024-03-30 14:04:11 +01:00
nu_common Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
pager Replace subtraction of Instants and Durations with saturating subtractions (#12549) 2024-04-17 07:25:16 -05:00
registry explore: remove :config, :show-config, :tweak commands (#10259) 2023-09-07 10:34:08 -05:00
views Reuse existing small allocations if possible (#12335) 2024-03-30 14:04:11 +01:00
default_context.rs Move explore command out of nu-command deps (#9421) 2023-06-14 01:18:36 +02:00
explore.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
lib.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00