[PATCH] rust: time: add `Delta::from_nanos`
From: Andreas Hindborg
Date: Sun Feb 15 2026 - 15:14:35 EST
Add a method to create a `Delta` from an amount of nanoseconds.
Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
rust/kernel/time.rs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
index 6ea98dfcd0278..2b096e5a61cda 100644
--- a/rust/kernel/time.rs
+++ b/rust/kernel/time.rs
@@ -363,6 +363,12 @@ impl Delta {
/// A span of time equal to zero.
pub const ZERO: Self = Self { nanos: 0 };
+ /// Create a new [`Delta`] from a number of nanoseconds.
+ #[inline]
+ pub const fn from_nanos(nanos: i64) -> Self {
+ Self { nanos }
+ }
+
/// Create a new [`Delta`] from a number of microseconds.
///
/// The `micros` can range from -9_223_372_036_854_775 to 9_223_372_036_854_775.
---
base-commit: 05f7e89ab9731565d8a62e3b5d1ec206485eeb0b
change-id: 20260215-time-from-nanos-86f8b10be4a2
Best regards,
--
Andreas Hindborg <a.hindborg@xxxxxxxxxx>