MCPcopy Create free account
hub / github.com/RustCV/RustCV / instant_to_duration

Method instant_to_duration

rustcv-core/src/time.rs:140–153  ·  view source on GitHub ↗
(&self, t: Instant)

Source from the content-addressed store, hash-verified

138 }
139
140 fn instant_to_duration(&self, t: Instant) -> Duration {
141 // 将 Instant 转换为 "System Up Time" (CLOCK_MONOTONIC)
142 // 这是一个平台相关的操作。
143 // 在 Linux 上 Instant 已经是 monotonic。
144 // 我们简单返回 elapsed。实际上应该对齐到 UNIX EPOCH 或 Boot Time。
145 // 这是一个 Placeholder。
146 // Duration::from_nanos(0)
147
148 // 第一次调用时会执行 Instant::now(),后续调用直接返回该值
149 let anchor = PROCESS_START_TIME.get_or_init(Instant::now);
150
151 // 使用 saturating_duration_since 防止在极端边缘情况下 (t 早于 anchor) panic
152 t.saturating_duration_since(*anchor)
153 }
154}

Callers 1

correctMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected