rust: time: Implement Add<Delta>/Sub<Delta> for Instant
authorLyude Paul <lyude@redhat.com>
Wed, 20 Aug 2025 20:26:43 +0000 (16:26 -0400)
committerAndreas Hindborg <a.hindborg@kernel.org>
Thu, 4 Sep 2025 14:56:48 +0000 (16:56 +0200)
commit22b65a40574e597e1919ca22cc3535c2b541f764
tree4830574870c357f63266cfbff38d3aca94387f16
parent4b0147494275fdbea98305f4ddad7e2def7b556f
rust: time: Implement Add<Delta>/Sub<Delta> for Instant

In order to copy the behavior rust currently follows for basic arithmetic
operations and panic if the result of an addition or subtraction results in
a value that would violate the invariants of Instant, but only if the
kernel has overflow checking for rust enabled.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20250820203704.731588-2-lyude@redhat.com
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
rust/kernel/time.rs