We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 57f1517 commit 4d95638Copy full SHA for 4d95638
embassy-time/src/instant.rs
@@ -57,6 +57,17 @@ impl Instant {
57
}
58
59
60
+ /// Try to create an Instant from a nanosecond count since system boot.
61
+ /// Fails if the number of nanoseconds is too large.
62
+ pub const fn try_from_nanos(nanos: u64) -> Option<Self> {
63
+ let Some(value) = nanos.checked_mul(TICK_HZ / GCD_1G) else {
64
+ return None;
65
+ };
66
+ Some(Self {
67
+ ticks: value / (1_000_000_000 / GCD_1G),
68
+ })
69
+ }
70
+
71
/// Try to create an Instant from a microsecond count since system boot.
72
/// Fails if the number of microseconds is too large.
73
pub const fn try_from_micros(micros: u64) -> Option<Self> {
0 commit comments